First calculate nodes for leaves present at height h
i = X NEW_LINE while ( nodes_last_level > 1 and i > 0 ) : NEW_LINE INDENT nodes_last_level = ceil ( nodes_last_level / 2 ) NEW_LINE i -= 1 NEW_LINE DEDENT from_leaf = nodes_last_level NEW_LINE