def find_solution(last_node):
    """
    Goes through all visited nodes via their parents, returns a list of the correct order in which we traversed the graph
    :param last_node: last node we checked
    :return: ordered list from first to last node.
    """
    solution = list()
    node = last_node
    while True:
        solution.append(node.id)
        if (node.parent == None):  # found the first node
            solution.reverse()
            return solution
        node = node.parent