skbio.core.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 skbio.core.tree import TreeNode
>>> tree = TreeNode.from_newick("((a,b)c);")
>>> for node in tree.preorder():
...     print node.name
None
c
a
b