Help, Tree Question. Not able to find the issue

Hi Guys, I am not able to find the issue with my solution for this problem https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/ and leetcode tree visualizer is also not working somehow which is making it harder to debug the failing test cases. Leetcode's tree structure is too obsucure for me to decipher the tree structure, I can blame my lack of experience on the platform for that. Any help is appreciated

public Node connect(Node root) {
        Node start = root;
            while(start != null){
                Node curr = start;
            while(curr !=null){
                if(curr.left != null){
                    curr.left.next = curr.right;
                }
                if(curr.right != null){
                    curr.right.next = getNextNode(curr.next);
                }
                curr = curr.next;    
            }
             start = start.left;
            }
      return root;  
    }
    
    public Node getNextNode(Node p){
        if(p == null){
            return p;
        }
        while(p != null){
            if(p.left !=null) return p.left;
            if(p.right !=null) return p.right;
            p = p.next;
        }
        return null;
    } 
	
I managed to spot and fix the issue following is the working solution.

public Node connect(Node root) {
        Node start = root;
            while(start != null){
                Node curr = start;
                while(curr !=null){
                    if(curr.left != null){
                        curr.left.next = curr.right ==null? getNextNode(curr.next): curr.right;
                    }
                    if(curr.right != null){
                        curr.right.next = getNextNode(curr.next);
                    }
                    curr = curr.next;    
                }
             start = getNextNode(start);
            }
      return root;  
    }
    
    public Node getNextNode(Node p){
        if(p == null){
            return p;
        }
        while(p != null){
            if(p.left !=null) return p.left;
            if(p.right !=null) return p.right;
            p = p.next;
        }
        return null;
    }
Comments (2)