code: public boolean next() {
      if (sketchAccessor_ == null) { // initial setup
        sketchAccessor_ = DoublesSketchAccessor.wrap(sketch_);
      } else { // advance index within the current level
        i_++;
      }
      if (i_ < sketchAccessor_.numItems()) {
        return true;
      }
      // go to the next non-empty level
      do {
        level_++;
        if (level_ > 0) {
          bits_ >>>= 1;
        }
        if (bits_ == 0L) {
          return false; // run out of levels
        }
        weight_ *= 2;
      } while ((bits_ & 1L) == 0L);
      i_ = 0;
      sketchAccessor_.setLevel(level_);
      return true;
    }
docs: Advancing the iterator and checking existence of the next entry
  is combined here for efficiency. This results in an undefined
  state of the iterator before the first call of this method.
  @return true if the next element exists