docs: DocumentSet add(QueryDocumentSnapshot document) {
      // Remove any prior mapping of the document's key before adding, preventing sortedSet from
      // accumulating values that aren't in the index.
      DocumentSet removed = remove(document.getReference().getResourcePath());
  
      ImmutableSortedMap<ResourcePath, QueryDocumentSnapshot> newKeyIndex =
          removed.keyIndex.insert(document.getReference().getResourcePath(), document);
      ImmutableSortedSet<QueryDocumentSnapshot> newSortedSet = removed.sortedSet.insert(document);
      return new DocumentSet(newKeyIndex, newSortedSet);
    }