Next right pointer

Still taking it easy. It's a binary tree week and just taking it easy because I'm tired.

problem

"""
# Definition for a Node.
class Node:
    def __init__(self, val: int = 0, left: 'Node' = None, right: 'Node' = None, next: 'Node' = None):
        self.val = val
        self.left = left
        self.right = right
        self.next = next
"""

class Solution:
    def connect(self, root):
        self.process_row([root])
        return root
    
    def process_row(self, row_list):
        next_row = []
        for n in row_list:
            if n == None:
                continue
            if n.left:
                next_row.append(n.left)
            if n.right:
                next_row.append(n.right)
        
        if not next_row:
            return

        for i, n in enumerate(next_row[:len(next_row)-1]):
            n.next = next_row[i+1]

        self.process_row(next_row)