def subtree_leaf_positions(subtree):
    """Return tree positions of all leaves of a subtree."""
    relative_leaf_positions = subtree.treepositions('leaves')
    subtree_root_pos = subtree.treeposition()
    absolute_leaf_positions = []
    for rel_leaf_pos in relative_leaf_positions:
        absolute_leaf_positions.append( subtree_root_pos + rel_leaf_pos)
    return absolute_leaf_positions
def subtree_leaf_positions ( subtree ) : relative_leaf_positions = subtree . treepositions ( 'leaves' ) subtree_root_pos = subtree . treeposition ( ) absolute_leaf_positions = [ ] for rel_leaf_pos in relative_leaf_positions : absolute_leaf_positions . append ( subtree_root_pos + rel_leaf_pos ) return absolute_leaf_positions
Return tree positions of all leaves of a subtree.