skbio.tree.TreeNode.preorder

TreeNode.preorder(include_self=True)[source]

Performs preorder iteration over tree

State: Experimental as of 0.4.0.

Parameters

include_self (bool) – 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.preorder():
...     print(node.name)
None
c
a
b