```
class Solution(object):
def isBalanced(self, root):
"""
:type root: TreeNode
:rtype: bool
"""
if root is None:
return True
else:
return self._is_node_balanced(root) and self.isBalanced(root.left) and self.isBalanced(root.right)
def _is_node_balanced(self, node):
return abs(self._depth(node.left) - self._depth(node.right)) <= 1
def _depth(self, node):
if node is None:
return 0
else:
return 1 + max(self._depth(node.left), self._depth(node.right))
```