Java Clean Recursive Solution
Code\njava []\n/**\n * Definition for a binary tree node.\n * public class TreeNode {\n * int val;\n * TreeNode left;\n * TreeNode right;\n * TreeNode() {}\n * 
# Code\n```java []\n/**\n * Definition for a binary tree node.\n * public class TreeNode {\n * int val;\n * TreeNode left;\n * TreeNode right;\n * TreeNode() {}\n * TreeNode(int val) { this.val = val; }\n * TreeNode(int val, TreeNode left, TreeNode right) {\n * this.val = val;\n * this.left = left;\n * this.right = right;\n * }\n * }\n */\nclass Solution {\n    public boolean flipEquiv(TreeNode root1, TreeNode root2) {\n        // Base case\n        if (root1 == null || root2 == null) {\n            return root1 == root2;\n        }\n\n        // When both the root.val are equals then check for left subtree and right subtree  or cross tree \n        // if any of the subtree is true then return true else false\n        return (root1.val == root2.val) &&\n                ((flipEquiv(root1.left, root2.right) && flipEquiv(root1.right, root2.left)) ||\n                (flipEquiv(root1.left, root2.left) && flipEquiv(root1.right, root2.right)));\n    }\n}\n```
['Tree', 'Depth-First Search', 'Recursion', 'Binary Tree', 'Java']