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