def apply_id_map(continuations, id_map):
    """
    Applies an id map to a set of continuations organized in
    dictionaries: face -> [continuations]
    """
    if not isinstance(continuations, dict):
        for continuation in continuations:
            continuation.segid = id_map[continuation.segid]
    else:
        for face, conts in continuations.items():
            for continuation in conts:
                continuation.segid = id_map[continuation.segid]
