def _get_node_path ( self , node ) : path = [ ] while node . up : path . append ( node . name ) node = node . up return list ( reversed ( path ) )
all root to leaf path in python
Return the path from the root to node as a list of node names .
def _get_node_path(self, node):
        """Return the path from the root to ``node`` as a list of node names."""
        path = []
        while node.up:
            path.append(node.name)
            node = node.up
        return list(reversed(path))