def group_filenames(filelist):
    """ Group entries in the form (id, filename, name) by filename. """
    filename_groups = dict()
    for pub_id, filename, name in filelist:
        if filename not in filename_groups.keys():
            filename_groups[filename] = list()
        filename_groups[filename].append((pub_id, name))
    return filename_groups
