Hi my algorithm is o((log n)^2) and it still can't pass the special judge, any idea why?

my code is as follows:

it checks the leftmost and rightmost nodes and if they are on the same level, then the nodes in this full complete tree is added, otherwise break the two subtrees and calculate the number of nodes in each separately.

```
class Solution:
# @param {TreeNode} root
# @return {integer}
def countNodes(self, root):
if not root:
return 0
h1=h2=0
node=root
while node:
h1+=1
node=node.left
node=root
while node:
h2+=1
node=node.right
if h1==h2:
return 2**h1-1
return self.countNodes(root.left)+self.countNodes(root.right)+1
```