skbio.tree.TreeNode.preorder

TreeNode.preorder(include_self=True)[source]

Performs preorder iteration over tree

Parameters:

include_self : bool

include the initial node if True

Returns:

GeneratorType

Yields successive TreeNode objects

Examples

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