def reconstruct_path(previous, target):
    """Reconstruct the path going back from target to original node in
    the 'previous' map of nodes."""    
    S = []
    current = target
    while current in previous:
        S = [current] + S
        current = previous[current]
    return S