[Python3] recursively
\n# class TreeNode(object):\n#     def __init__(self, x):\n#         self.val = x\n#         self.left = None\n#         self.right = None\n\n\n\nclass Solution
```\n# class TreeNode(object):\n#     def __init__(self, x):\n#         self.val = x\n#         self.left = None\n#         self.right = None\n\n\n\nclass Solution(object):\n    def isBalanced(self, root):\n        """\n        :type root: TreeNode\n        :rtype: bool\n        """ \n        if root == None:\n            return True\n        l = self.depth(root.left)\n        r = self.depth(root.right)\n        return (abs(l-r) <2) and self.isBalanced(root.left) and self.isBalanced(root.right)\n    \n    def depth(self,node):\n        if node == None: return 0\n        return max(self.depth(node.left),self.depth(node.right))+1\n```
['Python', 'Python3']