def _compressKerningPhase2(kerning):
    """
    >>> kerning = {
    ...     ("A", 100) : set(["A", "Aacute"]),
    ...     ("Aacute", 100) : set(["A", "Aacute"]),
    ...     ("A", 200) : set(["Agrave"]),
    ...     ("Agrave", 200) : set(["A"]),
    ...     ("A", 300) : set(["Adieresis"]),
    ... }
    >>> expected = {
    ...     (("A", "Aacute"), 100) : set(["A", "Aacute"]),
    ...     (tuple(["Agrave"]), 200) : set(["A"]),
    ...     (tuple(["A"]), 200) : set(["Agrave"]),
    ...     (tuple(["Adieresis"]), 300) : set(["A"]),
    ... }
    >>> result = _compressKerningPhase2(kerning)
    >>> result == expected
    True
    """
    # create a dict of form {(glyph2s, value) : set(glyph1s)}
    compressed = {}
    for (glyph1, value), glyph2List in kerning.items():
        k = (tuple(sorted(glyph2List)), value)
        if k not in compressed:
            compressed[k] = set()
        compressed[k].add(glyph1)
    return compressed