def get_except(data, i, ndata, end_value):
    """helper method for expand that gets the values until the end of an
    EXCEPT chain"""
    removed = []
    ivalue_old = 0
    while i < len(data):
        value = data[i]
        if isinstance(value, int):
            ivalue = value
        elif value.isdigit():
            ivalue = int(value)
        elif value == 'THRU':
            ivalue_old = int(data[i - 1])
            ivalue_new = int(data[i + 1])
            rangei = range(ivalue_old, ivalue_new + 1)
            removed.extend(rangei)
            i += 2
            continue
        else:
            raise NotImplementedError('data[%i] = %s; data=%s' % (i, value,
                data))
        if ivalue > end_value and ivalue > ivalue_old:
            break
        removed.append(ivalue)
        ivalue_old = ivalue
        i += 1
    removed_set = set(removed)
    return i, removed_set
