code: private int countValidLevelsBelow(final int tgtLvl) {
      int count = 0;
      long bitPattern = ds_.getBitPattern();
      for (int i = 0; (i < tgtLvl) && (bitPattern > 0); ++i, bitPattern >>>= 1) {
        if ((bitPattern & 1L) > 0L) {
          ++count;
        }
      }
      return count;
  
      // shorter implementation, testing suggests a tiny bit slower
      //final long mask = (1 << tgtLvl) - 1;
      //return Long.bitCount(ds_.getBitPattern() & mask);
    }
docs: Counts number of full levels in the sketch below tgtLvl. Useful for computing the level
  offset in a compact sketch.
  @param tgtLvl Target level in the sketch
  @return Number of full levels in the sketch below tgtLvl