def METHOD_NAME(v1, v2):
    """Safe comparison function for two (values containing) LooseVersion instances."""
    if not isinstance(v1, type(v2)):
        raise TypeError("Can't compare values of different types: %s (%s) vs %s (%s)" % (v1, type(v1), v2, type(v2)))
    # if we receive two iterative values, we need to recurse
    if isinstance(v1, (list, tuple)) and isinstance(v2, (list, tuple)):
        if len(v1) == len(v2):
            for x1, x2 in zip(v1, v2):
                res = METHOD_NAME(x1, x2)
                # if a difference was found, we know the result;
                # if not, we need comparison on next item (if any), done in next iteration
                if res != 0:
                    return res
            return 0  # no difference
        else:
            raise ValueError("Can only compare iterative values of same length: %s vs %s" % (v1, v2))
    def simple_compare(x1, x2):
        """Helper function for simple comparison using standard operators ==, <, > """
        if x1 < x2:
            return -1
        elif x1 > x2:
            return 1
        else:
            return 0
    if isinstance(v1, distutils.version.LooseVersion) and isinstance(v2, distutils.version.LooseVersion):
        # implementation based on '14894.patch' patch file provided in https://bugs.python.org/issue14894
        for ver1_part, ver2_part in zip_longest(v1.version, v2.version, fillvalue=''):
            # use string comparison if version parts have different type
            if not isinstance(ver1_part, type(ver2_part)):
                ver1_part = str(ver1_part)
                ver2_part = str(ver2_part)
            res = simple_compare(ver1_part, ver2_part)
            if res == 0:
                continue
            else:
                return res
        # identical versions
        return 0
    else:
        # for non-LooseVersion values, use simple comparison
        return simple_compare(v1, v2)