def convert_list_of_link_ids_to_network_nodes(network, link_ids: list):
    """
    Extracts nodes corresponding to link ids in the order of given link_ids list. Useful for extracting network routes.
    :param network:
    :param link_ids:
    :return:
    """
    paths = []
    connected_path = []
    for link_id in link_ids:
        x, y = network.link_id_mapping[link_id]['from'], network.link_id_mapping[link_id]['to']
        if not connected_path:
            connected_path = [x, y]
        elif connected_path[-1] != x:
            paths.append(connected_path)
            connected_path = [x, y]
        else:
            connected_path.append(y)
    paths.append(connected_path)
    return paths