code: public IScan add(IScan scan) {
      int num = scan.getNum();
  
      IScan oldScan = getNum2scan().put(num, scan);
      log.trace("Adding scan #{} to ScanIndex. num2scan map already contained a scan for scanNum: {}",
          num, num);
  
      final Double rt = scan.getRt();
      final TreeMap<Double, List<IScan>> rt2scan = getRt2scan();
      if (scan.getRt() != null) {
        List<IScan> scans = rt2scan.get(rt);
        if (scans == null) {
          // no entries for this RT yet
          scans = new ArrayList<>(1);
          scans.add(scan);
          getRt2scan().put(rt, scans);
        } else {
          // check if this scan was in the list
          boolean replaced = false;
          for (int i = 0; i < scans.size(); i++) {
            IScan s = scans.get(i);
            if (s.getNum() == scan.getNum()) {
              scans.set(i, scan);
              replaced = true;
              break;
            }
          }
            if (!replaced) {
                scans.add(scan);
            }
        }
      } else {
        log.debug("Adding scan # to ScanIndex. No RT.", num);
      }
      return oldScan;
    }
docs: Adds a scan to the index. If the scan has RT set to non-null, will also add it to RT index. If
  a scan with the same scan number was already in the index, then it will get replaced.
  
  @return if a scan with the same scan number was already in the index, then it will be returned.