def check(next_col, next_row, sub_nodes):
    if valid_cell(next_col, next_row):
        if (grid[(next_col, next_row)] == TERMINAL):
            backtrack_node = node
            while (backtrack_node is not None):
                if (backtrack_node.get_parent() is not None):
                    grid[(backtrack_node.get_col(), backtrack_node.get_row())] = PATH
                    draw_cell(PATH_CELL_COLOR, backtrack_node.get_col(), backtrack_node.get_row())
                    pygame.display.update()
                backtrack_node = backtrack_node.get_parent()
            return True
        elif ((grid[(next_col, next_row)] != WALL) and (grid[(next_col, next_row)] != VISITED) and (grid[(next_col, next_row)] != INITIAL)):
            grid[(next_col, next_row)] = VISITED
            draw_cell(VISITED_CELL_COLOR, next_col, next_row)
            pygame.display.update()
            child_node = bfs_node(next_col, next_row, node)
            sub_nodes.append(child_node)
    return False
def check(next_col, next_row, sub_nodes):
    if valid_cell(next_col, next_row):
        if (grid[(next_col, next_row)] == TERMINAL):
            backtrack_node = node
            while (backtrack_node is not None):
                if (backtrack_node.get_parent() is not None):
                    grid[(backtrack_node.get_col(), backtrack_node.get_row())] = PATH
                    draw_cell(PATH_CELL_COLOR, backtrack_node.get_col(), backtrack_node.get_row())
                    pygame.display.update()
                backtrack_node = backtrack_node.get_parent()
            return True
        elif ((grid[(next_col, next_row)] != WALL) and (grid[(next_col, next_row)] != VISITED) and (grid[(next_col, next_row)] != INITIAL)):
            grid[(next_col, next_row)] = VISITED
            draw_cell(VISITED_CELL_COLOR, next_col, next_row)
            pygame.display.update()
            child_node = bfs_node(next_col, next_row, node)
            sub_nodes.append(child_node)
    return False