docs: private void compressWhileUpdating() {
      final int level = findLevelToCompact();
  
      // It is important to do add the new top level right here. Be aware that this operation
      // grows the buffer and shifts the data and also the boundaries of the data and grows the
      // levels array and increments numLevels_
      if (level == (numLevels_ - 1)) {
        addEmptyTopLevelToCompletelyFullSketch();
      }
  
      final int rawBeg = levels_[level];
      final int rawLim = levels_[level + 1];
      // +2 is OK because we already added a new top level if necessary
      final int popAbove = levels_[level + 2] - rawLim;
      final int rawPop = rawLim - rawBeg;
      final boolean oddPop = KllHelper.isOdd(rawPop);
      final int adjBeg = oddPop ? rawBeg + 1 : rawBeg;
      final int adjPop = oddPop ? rawPop - 1 : rawPop;
      final int halfAdjPop = adjPop / 2;
  
      // level zero might not be sorted, so we must sort it if we wish to compact it
      if (level == 0) {
        Arrays.sort(items_, adjBeg, adjBeg + adjPop);
      }
      if (popAbove == 0) {
        KllHelper.randomlyHalveUp(items_, adjBeg, adjPop);
      } else {
        KllHelper.randomlyHalveDown(items_, adjBeg, adjPop);
        KllHelper.mergeSortedArrays(items_, adjBeg, halfAdjPop, items_, rawLim, popAbove,
            items_, adjBeg + halfAdjPop);
      }
      levels_[level + 1] -= halfAdjPop; // adjust boundaries of the level above
      if (oddPop) {
        levels_[level] = levels_[level + 1] - 1; // the current level now contains one item
        items_[levels_[level]] = items_[rawBeg]; // namely this leftover guy
      } else {
        levels_[level] = levels_[level + 1]; // the current level is now empty
      }
  
      // verify that we freed up halfAdjPop array slots just below the current level
      assert levels_[level] == (rawBeg + halfAdjPop);
  
      // finally, we need to shift up the data in the levels below
      // so that the freed-up space can be used by level zero
      if (level > 0) {
        final int amount = rawBeg - levels_[0];
        System.arraycopy(items_, levels_[0], items_, levels_[0] + halfAdjPop, amount);
        for (int lvl = 0; lvl < level; lvl++) {
          levels_[lvl] += halfAdjPop;
        }
      }
    }