Refine and thereby deduplicate bounding boxes to tighten them, but not too much.
The code is used to deduplicate bounding boxes. The focus here is on favouring smaller bounding boxes over larger bounding boxes, except when they are point-like.
More preparatory work for !682 (merged)
Edited by Adam Reichold