skbio.tree.TreeNode.ancestors

TreeNode.ancestors()[source]

Returns all ancestors back to the root

State: Experimental as of 0.4.0.

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:The path, toward the root, from self
Return type:list of TreeNode

Examples

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