skbio.tree.TreeNode.ancestors

TreeNode.ancestors()[source]

Returns all ancestors back to the root

This call will return all nodes in the path back to root, but does not include the node instance that the call was made from.

Returns:

list of TreeNode

The path, toward the root, from self

Examples

>>> from six import StringIO
>>> from skbio import TreeNode
>>> tree = TreeNode.read(StringIO("((a,b)c,(d,e)f)root;"))
>>> [node.name for node in tree.find('a').ancestors()]
['c', 'root']