from structures import build_tree

def same_tree(a, b):
    if a is None or b is None:
        return a is b
    return (a.val == b.val and same_tree(a.left, b.left)
            and same_tree(a.right, b.right))
