def reconstruct_path(came_from, current_node):
    """Reconstruct the path from the end node back to the beginning using the
    mapping of previous nodes.
    """

    total_path = [current_node]

    while current_node in came_from.keys():

        current_node = came_from[current_node]

        total_path.insert(0, current_node)

    return total_path