skbio.core.tree.TreeNode.postorder

TreeNode.postorder(include_self=True)[source]

Performs 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_self : bool

include the initial node if True

Returns:

GeneratorType

Yields successive TreeNode objects

Examples

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