Correctly handle overlapping graphicsitems