docs: private ItemsToPush missingRevisionsToJsonDocs(
              Map<String, DocumentRevisionTree> allTrees,
              Map<String, CouchClient.MissingRevisions> revisions) throws AttachmentException {
  
          ItemsToPush itemsToPush = new ItemsToPush();
  
          for(Map.Entry<String, CouchClient.MissingRevisions> e : revisions.entrySet()) {
              String docId = e.getKey();
              Set<String> missingRevisions = e.getValue().missing;
              DocumentRevisionTree tree = allTrees.get(docId);
              for(String rev : missingRevisions) {
                  long sequence = tree.lookup(docId, rev).getSequence();
                  List<InternalDocumentRevision> path = tree.getPathForNode(sequence);
  
                  // get the attachments for the leaf of this path
                  InternalDocumentRevision dr = path.get(0);
                  Map<String, ? extends Attachment> atts = this.sourceDb.getDbCore().attachmentsForRevision(dr);
  
                  // get common ancestor generation - needed to correctly stub out attachments
                  // closest back (first) instance of one of the possible ancestors rev ID in the history tree
                  int minRevPos = 0;
                  for (InternalDocumentRevision ancestor : path) {
                      if (e.getValue().possible_ancestors != null &&
                              e.getValue().possible_ancestors.contains(ancestor.getRevision())) {
                          minRevPos = ancestor.getGeneration();
                      }
                  }
  
                  // do we inline all attachments as base64 or send them all via multipart writer?
                  boolean shouldInline = RevisionHistoryHelper.shouldInline(atts,
                          this.pushAttachmentsInline,
                          minRevPos);
                  // get the json, and inline any small attachments
                  Map<String, Object> json = RevisionHistoryHelper.revisionHistoryToJson(path,
                          atts,
                          shouldInline,
                          minRevPos);
                  // if there are any large atts we will get a multipart writer, otherwise null
                  MultipartAttachmentWriter mpw = RevisionHistoryHelper.createMultipartWriter(json,
                          atts,
                          shouldInline,
                          minRevPos);
  
                  // now we will have either a multipart or a plain doc
                  if (mpw == null) {
                      itemsToPush.serializedDocs.add(JSONUtils.toJson(json));
                  } else {
                      itemsToPush.multiparts.add(mpw);
                  }
              }
          }
  
          return itemsToPush;
      }