import copy


def image_filter_range(json_dict, key, min_value=None, max_value=None, return_copy=True):
    """Return a version of `json_dict` where only `io` list items (images) with
    `key`'s value in range `[min_velue ; max_value]` are kept."""

    if return_copy:
        json_dict = copy.deepcopy(json_dict)

    if min_value is not None:
        json_dict["io"] = [image_dict for image_dict in json_dict["io"] if key in image_dict and min_value <= image_dict[key]]

    if max_value is not None:
        json_dict["io"] = [image_dict for image_dict in json_dict["io"] if key in image_dict and image_dict[key] <= max_value]

    return json_dict