def _update_backref(mapping, oldkey, newkey, value):
    """
    Updates references to make oldkey and newkey refer to the same
    type varable.
    """
    oldrefs = mapping.setdefault('backref', {}).setdefault(oldkey, set())
    newrefs = mapping.setdefault('backref', {}).setdefault(newkey, set())
    for oldref in oldrefs:
        mapping[oldref] = value
        newrefs.add(oldref)
        mapping['backref'][oldref] = newrefs
    mapping[oldkey] = value
    newrefs.add(oldkey)
    mapping['backref'][oldkey] = newrefs
