code: static QueryInterval[] prepareQueryIntervals( final List<Interval>
  			rawIntervals, final SAMSequenceDictionary sequenceDictionary ) {
  		if ( rawIntervals == null || rawIntervals.isEmpty() ) {
  			return null;
  		}
  
  		// Convert each SimpleInterval to a QueryInterval
  		final QueryInterval[] convertedIntervals =
  				rawIntervals.stream()
  						.map(rawInterval -> convertSimpleIntervalToQueryInterval(rawInterval, sequenceDictionary))
  						.toArray(QueryInterval[]::new);
  
  		// Intervals must be optimized (sorted and merged) in order to use the htsjdk query API
  		return QueryInterval.optimizeIntervals(convertedIntervals);
  	}
docs: Converts a List of SimpleIntervals into the format required by the SamReader query API
  @param rawIntervals SimpleIntervals to be converted
  @return A sorted, merged list of QueryIntervals suitable for passing to the SamReader query API