For two trees to be mirror images , the following three conditions must be true 1 - Their root node 's key must be same  2 - left subtree of left tree and right subtree  of the right tree have to be mirror images  3 - right subtree of left tree and left subtree  of right tree have to be mirror images
if ( root1 is not None and root2 is not None ) : NEW_LINE INDENT if root1 . key == root2 . key : NEW_LINE INDENT return ( isMirror ( root1 . left , root2 . right ) and isMirror ( root1 . right , root2 . left ) ) NEW_LINE DEDENT DEDENT