docs: private <ItemT> void addInternal(@Nonnull Iterable<ItemT> items) {
          // Note that items can be a large lazily evaluated collection,
          // so this method is optimized to only iterate through it as much as needed.
  
          if (!items.iterator().hasNext()) {
              return;
          }
  
          nextBuildNumber = getNextBuildNumber(items.iterator().next());
  
          if (newerThan == null && olderThan == null) {
              // Just return the first page of entries (newest)
              Iterator<ItemT> iter = items.iterator();
              while (iter.hasNext()) {
                  add(iter.next());
                  if (isFull()) {
                      break;
                  }
              }
              hasDownPage = iter.hasNext();
          } else if (newerThan != null) {
              int toFillCount = getFillCount();
              if (toFillCount > 0) {
                  // Walk through the items and keep track of the oldest
                  // 'toFillCount' items until we reach an item older than
                  // 'newerThan' or the end of the list.
                  LinkedList<ItemT> itemsToAdd = new LinkedList<>();
                  Iterator<ItemT> iter = items.iterator();
                  while (iter.hasNext()) {
                      ItemT item = iter.next();
                      if (HistoryPageEntry.getEntryId(item) > newerThan) {
                          itemsToAdd.addLast(item);
  
                          // Discard an item off the front of the list if we have
                          // to (which means we would be able to page up).
                          if (itemsToAdd.size() > toFillCount) {
                              itemsToAdd.removeFirst();
                              hasUpPage = true;
                          }
                      } else {
                          break;
                      }
                  }
                  if (itemsToAdd.size() == 0) {
                      // All builds are older than newerThan ?
                      hasDownPage = true;
                  } else {
                      // If there's less than a full page of items newer than
                      // 'newerThan', then it's ok to fill the page with older items.
                      if (itemsToAdd.size() < toFillCount) {
                          // We have to restart the iterator and skip the items that we added (because
                          // we may have popped an extra item off the iterator that did not get added).
                          Iterator<ItemT> skippedIter = items.iterator();
                          Iterators.skip(skippedIter, itemsToAdd.size());
                          for (int i = itemsToAdd.size(); i < toFillCount && skippedIter.hasNext(); i++) {
                              ItemT item = skippedIter.next();
                              itemsToAdd.addLast(item);
                          }
                      }
                      hasDownPage = iter.hasNext();
                      for (Object item : itemsToAdd) {
                          add(item);
                      }
                  }
              }
          } else if (olderThan != null) {
              Iterator<ItemT> iter = items.iterator();
              while (iter.hasNext()) {
                  Object item = iter.next();
                  if (HistoryPageEntry.getEntryId(item) >= olderThan) {
                      hasUpPage = true;
                  } else {
                      add(item);
                      if (isFull()) {
                          hasDownPage = iter.hasNext();
                          break;
                      }
                  }
              }
          }
      }