def __add(weights, index, increment, max_val, min_val):
    """
    Adds to a value to a specific index in a list of weights while thresholding the outcome to a minimum and maximum value.
    Creates new list of weights holding the result without altering the original.

    Args:
        weights: The list of weights.
        index: The element to add to.
        increment: The value to add.
        max_val: The maximum threshold.
        min_val: The mimimum threshold.
    """
    weights = [weight for weight in weights]
    weights[index] = min(max_val, max(min_val, weights[index]+increment))
    #if increment != 0 and (weights[index] == min_val or weights[index] == max_val):
    #    return None
    # normalize weights
    """
    min_weight = min(0, min(weights))
    if min_weight!=0:
        weights = [weight-min_weight for weight in weights]
    sum_weights = sum(weights)
    weights = [weight/sum_weights for weight in weights]
    """
    return weights