given two binary trees write a function to check if they are equal or not two binary trees are considered equal if they are structurally identical and the nodes have the same value time complexity ominn m where n and m are the number of nodes for the trees space complexity ominheight1 height2 levels of recursion is the mininum height between the two trees time complexity o min n m where n and m are the number of nodes for the trees space complexity o min height1 height2 levels of recursion is the mininum height between the two trees
def is_same_tree(tree_p, tree_q):
    if tree_p is None and tree_q is None:
        return True
    if tree_p is not None and tree_q is not None and tree_p.val == tree_q.val:
        return is_same_tree(tree_p.left, tree_q.left) and is_same_tree(tree_p.right, tree_q.right)
    return False