class DocumentSet implements Iterable<Document> {

  @Nullable
  public Document getPredecessor(DocumentKey key) {
    Document document = keyIndex.get(key);
    if (document == null) {
      throw new IllegalArgumentException("Key not contained in DocumentSet: " + key);
    }
    return sortedSet.getPredecessorEntry(document);
  }

  private  DocumentSet(
      ImmutableSortedMap<DocumentKey, Document> keyIndex, ImmutableSortedSet<Document> sortedSet);

}