Checking if a tree is balanced I'm trying to implement balanced tree checking by python like following. 

# Balanced tree definition:
# if tree's left and right sub tree are balanced, and their height difference is not bigger than 1, then the tree is balanced else not.

class Node:
    def __init__(self, val):
        self.left = None
        self.right = None
        self.val = val

def is_balanced(root):
    # root: Node
    # return: boolean
    ret, h = is_balanced_helper(root)
    return ret

def is_balanced_helper(root):
    if not root:
        return True, 0
    else:
        retl, hl = is_balanced_helper(root.left)
        retr, hr = is_balanced_helper(root.right)
        h = max(hr, hl)+1
        if retl and retr:
            return abs(hl-hr) &lt; 2, h
        else:
            return False, h


Please help me review above code. 

And I feel returning 2 return values are not elegant. And return -1 when the tree is not balanced is also not elegant. Or shall I raise exception when tree is not balanced? What's your suggestion when handle such case?
Refer here for the definition of a balanced binary tree. If you don't like having two return values, you can always refactor and write a separate height() function to get the height of a tree. This would allow you to implement it without having to return two values and would improve the readability of your code as well. This is the suggested way to do it.

I would say avoid raising exceptions unless you're certain you know you want to. You should never raise an exception if you don't have to.