✅ One Line Solution
(Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)\n\n# Code #1.1 - Basic Version\nTime complexity: O(
(Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)\n\n# Code #1.1 - Basic Version\nTime complexity: $$O(n)$$. Space complexity: $$O(n)$$.\n```python3\nclass Solution:\n    def flipEquiv(self, n: Optional[TreeNode], u: Optional[TreeNode]) -> bool:\n        return bool((f:=lambda n,u:n==u or n and u and n.val==u.val and (f(n.left,u.left) and f(n.right,u.right) or f(n.left,u.right) and f(n.right,u.left)))(n,u))\n```\n\n# Code #1.2 - Unwrapped\n```python3\nclass Solution:\n    def flipEquiv(self, n: Optional[TreeNode], u: Optional[TreeNode]) -> bool:\n        def f(n, u):\n            if n == u:\n                return True\n                \n            if n and u and n.val == u.val \\\n                and (f(n.left, u.left) and f(n.right, u.right) \n                    or f(n.left, u.right) and f(n.right, u.left)):\n                return True\n        \n        return bool(f(n, u))\n```\n\n# Code #2 - Shorter Version\nTime complexity: $$O(n)$$. Space complexity: $$O(n)$$.\n```python3\nclass Solution:\n    def flipEquiv(self, n: Optional[TreeNode], u: Optional[TreeNode]) -> bool:\n        return (f:=lambda n,u:n==u or n!=None!=u and n.val==u.val and f(p:=n.left,q:=u.left)*f(w:=n.right,e:=u.right)+f(p,e)*f(w,q))(n,u)>0\n```\n\n(Disclaimer 2: code above is just a product of fantasy packed into one line, it is not claimed to be \'true\' oneliners - please, remind about drawbacks only if you know how to make it better)
['Tree', 'Depth-First Search', 'Binary Tree', 'Python', 'Python3']