code: private QueryResult<S, O> filterAndProcessQuery(Word<I> query,
                                                      Word<O> partialOutput,
                                                      Function<Word<I>, QueryResult<S, O>> processQuery) {
          final LinkedList<I> filteredQueryList = new LinkedList<>(query.asList());
          final Iterator<I> queryIterator = filteredQueryList.iterator();
  
          // filter "reflexive" edges
          for (final O outputSymbol : partialOutput) {
              queryIterator.next();
              if (outputSymbol != null) {
                  queryIterator.remove();
              }
          }
  
          // process the query
          final QueryResult<S, O> res = processQuery.apply(Word.fromList(filteredQueryList));
  
          final WordBuilder<O> wordBuilder = new WordBuilder<>();
          final Iterator<O> resultIterator = res.output.iterator();
  
          // insert back the a priori available outputs of "reflexive" edges
          for (final O output : partialOutput) {
              if (output == null) {
                  wordBuilder.add(resultIterator.next());
              } else {
                  wordBuilder.add(output);
              }
          }
  
          return new QueryResult<>(wordBuilder.toWord(), res.newState);
      }
docs: Filters all the query elements corresponding to "reflexive" edges in the reuse tree, executes the shorter query,
  and fills the filtered outputs into the resulting output word.
  
  @param query
  the input query with "reflexive" symbols (may be a suffix of the original query, if a system state is
  reused).
  @param partialOutput
  the output information from the tree with {@code null} entries for all "non-reflexive" edges.
  @param processQuery
  a function that actually processes the (shortened) query.
  
  @return the query result including the outputs of the "reflexive" symbol executions.