def waypoints_from_dict(list_key, waypoint_lists):
    """Given the waypoint list you want, and the dict of waypoint lists, return a
    list of waypoints.

    A key in the waypoint_lists dict can have a value of either a list or a
    single string. In the case of a single string, it is assumed to refer to the
    key of another list.

    """

    # while rather than recursion for simplicity
    while isinstance(list_key, str):
        if list_key not in waypoint_lists:
            return []
        list_key = waypoint_lists[list_key]

    return list_key