code: public static void finalizePrecursorWindows(IScanCollection scans) {
      TreeMap<Integer, IntervalST<Double, TreeMap<Integer, IScan>>> mapMsLevel2rangeGroups = scans
          .getMapMsLevel2rangeGroups();
  
      List<Integer> msLevelsToRemove = new ArrayList<>();
  
      msLevelLoop:
      for (Map.Entry<Integer, IntervalST<Double, TreeMap<Integer, IScan>>> entry : mapMsLevel2rangeGroups
          .entrySet()) {
  
        int msLevel = entry.getKey();
        IntervalST<Double, TreeMap<Integer, IScan>> rangeMapMS2 = entry.getValue();
  
        if (rangeMapMS2.size() == 1) {
          msLevelsToRemove.add(msLevel);
        } else {
          // if we have a precursor range map, we want to see if it actually contains
          // ranges that have lots of MS2 spectra in them.
          // ALL ranges are required to have more than 1 MS2 spectra
  
          for (IntervalST.Node<Double, TreeMap<Integer, IScan>> node : rangeMapMS2) {
            if (node.getValue().size() <= 1) {
              // if we didn't have at least 1 scans in even one range, then discard the whole sub-tree
              msLevelsToRemove.add(msLevel);
              continue msLevelLoop;
            }
          }
  
          // we also check that all ranges contain approximately equal amount of scans
          // THIS WILL NOT WORK FOR MSX DATA, UNLESS "maxScanCountDiff" is set to some large value, which
          // should be at least [ms1_mz_range / (msx_isolation_width * msx_multiplex_number)]
          if (!isAllRangesHaveApproxSameScanCounts(rangeMapMS2)) {
            msLevelsToRemove.add(msLevel);
            continue msLevelLoop;
          }
  
          // otherwise we just keep it there, but the tree needs to be recreated, because the ranges are incorrect
        }
      }
        for (Integer msLevel : msLevelsToRemove) {
            mapMsLevel2rangeGroups.remove(msLevel);
        }
    }
docs: Calling this method only makes sense if the whole LC/MS structure has been parsed.
  
  @param scans the scan collection, it will be modified in-place