def compareTuples(new, old):
    """Compare two tuples.

    Return (common_prefix, middle_of_old, middle_of_new, common_suffix)
    """
    first = 0
    for oldval, newval in zip(old, new):
        if oldval != newval:
            break
        first += 1
    last = 0
    for oldval, newval in zip(reversed(old[first:]), reversed(new[first:])):
        if oldval != newval:
            break
        last += 1
    return old[:first], old[first:len(old) - last], new[first:len(new) - last
        ], old[len(old) - last:]
