(root)
return 1 + max(left, right)
return 0 if unbalanced else depth + 1
return 0 if unbalanced else depth + 1
return 0 if unbalanced else depth + 1
def __get_depth(root):
    """
    return 0 if unbalanced else depth + 1
    """
    if root is None:
        return 0
    left  = __get_depth(root.left)
    right = __get_depth(root.right)
    if abs(left-right) > 1 or -1 in [left, right]:
        return -1
    return 1 + max(left, right)
def __get_depth ( root ) : if root is None : return 0 left = __get_depth ( root . left ) right = __get_depth ( root . right ) if abs ( left - right ) > 1 or - 1 in [ left , right ] : return - 1 return 1 + max ( left , right )