Suppose there is a tree $Root$, now starting from $Root's$ root node, if the distance to $Root's$ left-most child node equals to the distance to the right-most child node, we can calculate the total number of tree nodes of $Root$ directly. Since we don't have to scan every node of the tree, the time complexity of algorithm is $O(h^2)$.

There is no Chinese input method in Company's computer...