<qiyuangong>116_Populating_Next_Right_Pointers_in_Each_Node_1.py
def connect( root):
    if root is None:
        return
    nodes = [root]
    while len(nodes) != 0:
        next_step = []
        last = None
        for node in nodes:
            if last is not None:
                last.next = node
            if node.left is not None:
                next_step.append(node.left)
            if node.right is not None:
                next_step.append(node.right)
            last = node
        nodes = next_step
def sample_funcname ( var_0 ) :
    if var_0 is None :
        return
    var_2 = [ var_0 ]
    while len ( var_2 ) != 0 :
        var_5 = [ ]
        var_6 = None
        for var_7 in var_2 :
            if var_6 is not None :
                var_6.next = var_7
            if var_7.left is not None :
                var_5.append ( var_7.left )
            if var_7.right is not None :
                var_5.append ( var_7.right )
            var_6 = var_7
        var_2 = var_5
