Python Simple Solution easy to understand | O(n) and constant Memory
\n def helper(self, root, parent=None, isleftChild=True):\n        if root is None:\n            return None\n        \n        if parent == None:\n            
```\n def helper(self, root, parent=None, isleftChild=True):\n        if root is None:\n            return None\n        \n        if parent == None:\n            #we are at root\n            root.next = None\n        else:\n            #we are at some node other than root\n            if isleftChild:\n                root.next = parent.right\n            else:\n                root.next = None\n                if parent.next != None:\n                    root.next = parent.next.left\n                    \n        root.left = self.helper(root.left, root, True)\n        root.right = self.helper(root.right, root, False)\n        \n        return root\n    \n    def connect(self, root: \'Node\') -> \'Node\':\n        return self.helper(root)\n```\nplease upvote !
['Python', 'C++', 'Java', 'Python3']