'Try to unify the two given types.  A third type is returned,
or None in case of failure.'

def unify_pairs(self, first, second):

    if (first == second):
        return first
    if (first is types.undefined):
        return second
    elif (second is types.undefined):
        return first
    unified = first.unify(self, second)
    if (unified is not None):
        return unified
    unified = second.unify(self, first)
    if (unified is not None):
        return unified
    conv = self.can_convert(fromty=first, toty=second)
    if ((conv is not None) and (conv <= Conversion.safe)):
        return second
    conv = self.can_convert(fromty=second, toty=first)
    if ((conv is not None) and (conv <= Conversion.safe)):
        return first
    return None
