skbio.tree.TreeNode.postorder#

TreeNode.postorder(include_self=True)[source]#

Perform postorder iteration over tree.

This is somewhat inelegant compared to saving the node and its index on the stack, but is 30% faster in the average case and 3x faster in the worst case (for a comb tree).

Parameters:
include_selfbool

include the initial node if True

Yields:
TreeNode

Traversed node.

Examples

>>> from skbio import TreeNode
>>> tree = TreeNode.read(["((a,b)c);"])
>>> for node in tree.postorder():
...     print(node.name)
a
b
c
None