Skip to main content
`Ctrl`+`K`

# skbio.tree.TreeNode.postorder

TreeNode.postorder(include_self=True)

  Perform postorder traversal over tree.

  Parameters:
    include_self bool, optional

      Include the initial node if True (default).

  Yields:
    TreeNode

      Visited node.

  See also

  `traverse`
  `preorder`
  `pre_and_postorder`
  `levelorder`

  Notes

  Postorder traversal traverses all children of a node in order before visiting the parent node. It is also known as LRN (left - right - node). It is a depth-first search (DFS). The overall direction of traversal is from tips to root.

  Examples

      >>> from skbio import TreeNode
      >>> tree = TreeNode.read(["((a,b)c,(d,e)f)g;"])
      >>> print(tree.ascii_art())
                          /-a
                /c-------|
               |          \-b
      -g-------|
               |          /-d
                \f-------|
                          \-e

      >>> for node in tree.postorder():
      ...     print(node.name)
      a
      b
      c
      d
      e
      f
      g