private <R> void getChildren(final Key parentKey,
                                 final OpenGroups openGroups,
                                 final ItemMapper<R> mapper,
                                 final OffsetRange range,
                                 final FetchState fetchState,
                                 final Consumer<R> resultConsumer) {
        final ItemsImpl items = childMap.get(parentKey);
        if (items == null) {
            return;
        }
        final List<ItemImpl> list = items.copy();

        // Transfer the sorted items to the result.
        for (final Item item : list) {
            fetchState.totalRowCount++;
            if (!fetchState.reachedRowLimit) {
                if (range.getOffset() <= fetchState.offset) {
                    final R row = mapper.create(item);
                    resultConsumer.accept(row);
                    fetchState.length++;
                    fetchState.reachedRowLimit = fetchState.length >= range.getLength();
                    if (fetchState.reachedRowLimit) {
                        if (fetchState.countRows) {
                            fetchState.justCount = true;
                        } else {
                            fetchState.keepGoing = false;
                        }
                    }
                    fetchState.offset++;
                }
            }

            // Add children if the group is open.
            if (fetchState.keepGoing && openGroups.isOpen(item.getKey())) {
                getChildren(item.getKey(),
                        openGroups,
                        mapper,
                        range,
                        fetchState,
                        resultConsumer);
            }
        }
    }
Add some values to the data store.

@param values The values to add to the store.
stroom-query/stroom-query-common/src/main/java/stroom/query/common/v2/MapDataStore.java