def remove_tracks(all_tracks, track_ids_to_remove):
    """
    Removes selected track ids from the set of all tracks.
    Args:
        all_tracks: dict containing all trajectories
        track_ids_to_remove: list of track ids to remove from all tracks

    Returns: dict containing all trajectories

    """
    for track_id in set(track_ids_to_remove):
        track = all_tracks.pop(track_id)
        if track.pred_track_id not in [[0], []]:
            # remove as succ in pred tracks
            for predecessor in track.pred_track_id:
                if predecessor in all_tracks:
                    if track_id in all_tracks[predecessor].successors:
                        all_tracks[predecessor].successors.remove(track_id)
        if len(track.successors) > 0:
            # remove as predecessor in succ tracks
            for successor in track.successors:
                if successor in all_tracks:
                    if track_id in all_tracks[successor].pred_track_id:
                        all_tracks[successor].pred_track_id.remove(track_id)
    return all_tracks