Returns a new "protToPeps" dictionary with entries merged that are
    present in proteinLists.

    NOTE:
        The key of the merged entry is a tuple of the sorted protein keys. This
        behaviour might change in the future; the tuple might be replaced by
        simply one of the protein entries which is then representative for all.

    :param proteinLists: a list of protein groups that will be merged
        [{protein, ...}, ...]
    :param protToPeps: dict, for each protein (=key) contains a set of
        associated peptides (=value). For Example {protein: {peptide, ...}, ...}
    :returns: dict, {protein: set([peptid, ...])}

def _mergeProteinEntries(proteinLists, protToPeps):
    """Returns a new "protToPeps" dictionary with entries merged that are
    present in proteinLists.

    NOTE:
        The key of the merged entry is a tuple of the sorted protein keys. This
        behaviour might change in the future; the tuple might be replaced by
        simply one of the protein entries which is then representative for all.

    :param proteinLists: a list of protein groups that will be merged
        [{protein, ...}, ...]
    :param protToPeps: dict, for each protein (=key) contains a set of
        associated peptides (=value). For Example {protein: {peptide, ...}, ...}
    :returns: dict, {protein: set([peptid, ...])}
    """
    mergedProtToPeps = dict(protToPeps)
    for proteins in proteinLists:
        for protein in proteins:
            peptides = mergedProtToPeps.pop(protein)
        mergedProtein = tuple(sorted(proteins))
        mergedProtToPeps[mergedProtein] = peptides
    return mergedProtToPeps