docs: private Integer advanceToDoc(int target) throws IOException {
      if (docId == NO_MORE_DOCS || target <= docId) {
        return null;
      } else {
        Integer spanDocId;
        Integer newDocId = target;
        for (QueueItem item : queueSpans) {
          if (item.sequenceSpans.spans != null) {
            if (item.sequenceSpans.spans.docID() < newDocId) {
              spanDocId = item.sequenceSpans.spans.advance(newDocId);
              if (spanDocId.equals(NO_MORE_DOCS)) {
                item.noMoreDocs = true;
                if (!item.sequenceSpans.optional) {
                  // a not optional span has NO_MORE_DOCS: stop
                  docId = NO_MORE_DOCS;
                  return null;
                }
              } else {
                if (!spanDocId.equals(newDocId) && !item.sequenceSpans.optional) {
                  // a not optional span has nothing for newDocId: stop
                  return spanDocId;
                }
              }
            } else if (item.sequenceSpans.spans.docID() != newDocId) {
              spanDocId = item.sequenceSpans.spans.docID();
              if (!item.sequenceSpans.optional) {
                // a not optional span seems to have nothing for newDocId: stop
                return spanDocId;
              }
            }
          }
        }
        // find match
        docId = newDocId;
        ignoreItem.advanceToDoc(docId);
        // try and glue together
        if (findMatches()) {
          return null;
          // no matches
        } else {
          resetQueue();
          // try next document
          return (newDocId + 1);
        }
      }
    }