import copy


def split_by_longest_dimension(region):
    """ Splits given region, (hyper)rectangle, into two by splitting the longest dimension in halves """
    index, maximum = 0, 0
    for i in range(len(region)):
        value = region[i][1] - region[i][0]
        if value > maximum:
            index = i
            maximum = value
    low = region[index][0]
    high = region[index][1]

    ## Compute the half of region
    threshold = low + (high - low) / 2

    ##  Update space
    model_low = copy.deepcopy(region)
    model_low[index] = [low, threshold]
    model_high = copy.deepcopy(region)
    model_high[index] = [threshold, high]
    return [model_low, model_high, index, threshold]