skbio.tree.TreeNode.non_tips#

TreeNode.non_tips(include_self=False)[source]#

Iterate over non-tip nodes descended from the current node.

Parameters:
include_selfbool, optional

Whether to include the initial node if it is not a tip (default: False).

Yields:
TreeNode

Visited non-tip node.

See also

tips
postorder

Notes

Nodes are ordered by a postorder traversal of the tree. The order is consistent between calls.

Examples

>>> from skbio import TreeNode
>>> tree = TreeNode.read(["((a,b)c,(d,e)f);"])
>>> print(tree.ascii_art())
                    /-a
          /c-------|
         |          \-b
---------|
         |          /-d
          \f-------|
                    \-e
>>> for node in tree.non_tips():
...     print(node.name)
c
f