Populating Next Right Pointer in Each Node

if(root.right!=null){
            if(root.next!=null)
                root.right.next = root.next.left;
            else
                root.right.next = null;
        }