def modify(boxes, modifier_fns):
    """ Modifies boxes according to the modifier functions.

    Args:
        boxes (dict or list): Dictionary containing box objects per image ``{"image_id": [box, box, ...], ...}`` or list of bounding boxes
        modifier_fns (list): List of modifier functions that get applied

    Returns:
        (dict or list): boxes after modifications

    Warning:
        These modifier functions will mutate your bounding boxes and some of them can even remove bounding boxes.
        If you want to keep a copy of your original values, you should pass a copy of your bounding box dictionary:

        >>> import copy
        >>> import brambox.boxes as bbb
        >>>
        >>> new_boxes = bbb.modify(copy.deepcopy(boxes), [modfier_fns, ...])
    """

    if isinstance(boxes, dict):
        for _, values in boxes.items():
            for i in range(len(values)-1, -1, -1):
                for fn in modifier_fns:
                    values[i] = fn(values[i])
                    if values[i] is None:
                        del values[i]
                        break
    else:
        for i in range(len(boxes)-1, -1, -1):
            for fn in modifier_fns:
                boxes[i] = fn(boxes[i])
                if boxes[i] is None:
                    del boxes[i]
                    break

    return boxes