class JcrChildNodeIterator implements NodeIterator {

    @Override
    public long getSize() {
        if (size > -1L) return size;
        if (!hasNext()) {
            // There are no more, so return the number of nodes we've already seen ...
            size = resolvedNode == null ? ndx : ndx + 1;
            return size;
        }
        // Otherwise, we have to iterate through the remaining iterator and keep the results ...
        List<Node> remainingNodes = new LinkedList<>();
        if (resolvedNode != null) {
            //we've already looked ahead once, so take that into account
            size = ndx + 1;
            remainingNodes.add(resolvedNode);
            resolvedNode = null;
        } else {
            size = ndx;
        }

        while (iterator.hasNext()) {
            Node node = resolver.nodeFrom(iterator.next());
            if (node != null) {
                remainingNodes.add(node);
                ++size;
            }
        }
        nodeIterator = remainingNodes.iterator();
        return size;
    }

      JcrChildNodeIterator( NodeResolver resolver,
                          Iterator<ChildReference> iterator );
      JcrChildNodeIterator( NodeResolver resolver,
                          ChildReferences childReferences );

}