code: private Object writeCounted(final SerIterator itemIterator) {
          List<Object> result = new ArrayList<>();
          while (itemIterator.hasNext()) {
              itemIterator.next();
              Object outputValue = writeObject(itemIterator.valueType(), itemIterator.value(), itemIterator);
              int outputCount = itemIterator.count();
              result.add(Arrays.asList(outputValue, outputCount));
          }
          return result;
      }
docs: write counted set