```
class Solution(object):
def isBalanced(self, root):
"""
:type root: TreeNode
:rtype: bool
"""
if not root: return True
return bool(self.depthBalance(root, 0))
def depthBalance(self, node, depth):
if not node: return depth
l = self.depthBalance(node.left, depth+1)
r = self.depthBalance(node.right, depth+1)
if not l or not r or abs(l-r) > 1:
return False
else:
return max(l, r)
```