Java solution traversing by level without extra space
public class Solution {\n        public void connect(TreeLinkNode root) {\n            if(root==null) return;\n            TreeLinkNode cur = root;\n           
    public class Solution {\n        public void connect(TreeLinkNode root) {\n            if(root==null) return;\n            TreeLinkNode cur = root;\n            TreeLinkNode nextLeftmost = null;\n\n            while(cur.left!=null){\n                nextLeftmost = cur.left; // save the start of next level\n                while(cur!=null){\n                    cur.left.next=cur.right;\n                    cur.right.next = cur.next==null? null : cur.next.left;\n                    cur=cur.next;\n                }\n                cur=nextLeftmost;  // point to next level \n            }\n        }\n    }
[]