[Java] Easy 100% DFS solution
java\n/**\n * Definition for a binary tree node.\n * public class TreeNode {\n *     int val;\n *     TreeNode left;\n *     TreeNode right;\n *     TreeNode() 
```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        if(root1 == null && root2 == null) return true;\n        if(root1 == null || root2 == null) return false;\n        if(root1.val != root2.val) return false;\n\n        if(\n            flipEquiv(root1.left, root2.left) && flipEquiv(root1.right, root2.right) ||\n            flipEquiv(root1.left, root2.right) && flipEquiv(root1.right, root2.left)\n        )\n            return true;\n        return false;\n    }\n}\n```
['Java']