target_leafpos = np.treeposition() + np.leaf_treeposition(0)
all_leaf_treepositions = t.treepositions('leaves')
x = all_leaf_treepositions.index(target_leafpos)
How many leaves are there before a subtree?