@staticmethod
def optimize_range(ranges):
    """Simplify/Combine a parsed list of ranges

        Examples:
            optimize_range([(2,4), (4,6), (5,8)]) -> [(2,8)]
            optimize_range([(1,1), (2,2), (3,6), (8,9))]) -> [(1,6), (8,9)]
        """
    if len(ranges) <= 1:
        return ranges
    ranges.sort()
    riter = iter(ranges)
    result = []
    beg, end = next(riter)
    for lower, upper in riter:
        if lower > end + 1:
            result.append((beg, end))
            beg, end = lower, upper
        elif upper > end:
            end = upper
    result.append((beg, end))
    return result
