static L mergeIntRangesCloserThan(final int threshold, L l) { new L out; for (IntRange r : l) if (nempty(out) && r.start <= last(out).end+threshold) replaceLast(out, intRange(last(out).start, r.end)); else out.add(r); ret out; }