An iterative java solution
public void connect(TreeLinkNode root) {\n        \n        TreeLinkNode n = root;\n        \n        while(n != null && n.left != null) {\n            TreeLink
    public void connect(TreeLinkNode root) {\n        \n        TreeLinkNode n = root;\n        \n        while(n != null && n.left != null) {\n            TreeLinkNode pre = null;\n            \n            for(TreeLinkNode p = n; p != null; p = p.next) {\n                if(pre != null) pre.next = p.left;\n                p.left.next = p.right;\n                pre = p.right;\n            }\n            n = n.left;\n        }\n    }
[]