[disjoint][segment-box] factor-out common code in disjoint_segment_box_impl