public FieldSelection intersect(FieldRange range) {
		FieldSelection intersection = new FieldSelection();

		int insertIndex = Collections.binarySearch(ranges, range);

		// if exact match, return it
		if (insertIndex >= 0) {
			intersection.addRange(range);
			return intersection;
		}

		insertIndex = -insertIndex - 2;
		if (insertIndex < 0) {
			insertIndex++;
		}

		while (insertIndex < ranges.size()) {
			FieldRange searchRange = ranges.get(insertIndex);
			if (searchRange.start.compareTo(range.end) >= 0) {
				break;
			}
			FieldRange newRange = searchRange.intersect(range);
			if (newRange != null) {
				intersection.addRange(newRange);
			}
			insertIndex++;
		}

		return intersection;
	}
Insert all fields in the ranges in the given field selection from this one.
@param selection the field selection fields to add to this field selection.
Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/support/FieldSelection.java