public void produce(RuleEvaluation e, int ignored) {
        ReferencedMatches referencedMatches = e.getReferencedMatches(reference);
        if (referencedMatches == null)
            throw new EvaluationException("Referred match '" + reference + "' not found");
        if (replacing) {
            e.removeMatches(referencedMatches);
        }

        var match = referencedMatches.matchIterator().next();
        if (produceAll) {
            // produce all terms in the condition
            NamedCondition namedCondition = e.getEvaluation().ruleBase().getCondition(referencedMatches.getContextName());
            ChoiceCondition choices = (ChoiceCondition)namedCondition.getCondition();
            List<Item> items = new ArrayList<>();
            for (Iterator<Condition> i = choices.conditionIterator(); i.hasNext();) {
                Condition condition = i.next();
                if (condition instanceof TermCondition) {
                    items.add(match.toItem(getLabel(), ((TermCondition)condition).term()));
                }
                else if (condition instanceof SequenceCondition) {
                    PhraseItem phrase = new PhraseItem(getLabel());
                    for (var term : ((SequenceCondition)condition).conditions())
                        phrase.addItem(match.toItem(getLabel(), ((TermCondition)term).term()));
                    items.add(phrase);
                }
                else {
                    // Until we validate this at construction time
                    throw new EvaluationException("Could not produce all terms in " + namedCondition + " as it is " +
                                                  "not a term or sequence condition");
                }
            }
            produce(e, match, items, 0);
        }
        else {
            // produce just the matching term
            produce(e, match, List.of(referencedMatches.toItem(getLabel())), 0);
        }
    }
Returns the label of the condition this should take its value from, never null
container-search/src/main/java/com/yahoo/prelude/semantics/rule/ReferenceTermProduction.java