def _get_optimal_path(predecessors, start_node, node, hash_fn):
    """Reconstruct the optimal path from the start to the current node."""

    path = [node]
    hashed_start = hash_fn(start_node)

    # Backtrack until starting node is found
    while hash_fn(node) != hashed_start:
        node = predecessors[hash_fn(node)]
        path.append(node)
    path.reverse()

    return path