.docname {Pipeline - Tree traversal}
.include {docs}

> Main packages: .repolink {`core.ast.iterator`} {tree/main/quarkdown-core/src/main/kotlin/com/quarkdown/core/ast/iterator}, .repolink {`core.context.hooks`} {tree/main/quarkdown-core/src/main/kotlin/com/quarkdown/core/context/hooks}

After the function calls have been expanded, the AST is traversed depth-first to gather enriched information about the document, such as:
- Heading hierarchy, used for the [table of contents](table-of-contents.qd)
- [Numbering](numbering.qd): each heading, figure, and other numbered element is assigned a unique number based on its location in the heading hierarchy
- Link definition bound to each link reference

For performance reasons, only one traversal is performed during this stage. Each operation can however act independently by attaching its own *hook* to the tree iterator, which is triggered when nodes of a certain kind are encountered.