Code in a with-pprint block or a method on pprint* can build up a tree of sections. A section is either a text node or a block which itself consists of sections.
Once the output sections have been generated, the tree of sections is traversed and intelligent decisions are made about indentation and line breaks. Finally, text is output.