Fork me on GitHub"

# skbio.tree.TreeNode.traverse

`TreeNode.``traverse`(self_before=True, self_after=False, include_self=True)

  Returns iterator over descendants

  State: Experimental as of 0.4.0.

  This is a depth-first traversal. Since the trees are not binary, preorder and postorder traversals are possible, but inorder traversals would depend on the data in the tree and are not handled here.

  Parameters:

  - self_before (bool) – includes each node before its descendants if True
  - self_after (bool) – includes each node after its descendants if True
  - include_self (bool) – include the initial node if True
  - and self_after are independent. If neither is True, (self_before) –
  - terminal nodes will be returned. (only) –
  - that if self is terminal, it will only be included once even if (Note) –
  - and self_after are both True. (self_before) –

  Yields: | TreeNode – Traversed node.

  See also

  `preorder()`, `postorder()`, `pre_and_postorder()`, `levelorder()`, `tips()`, `non_tips()`

  Examples

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