@Override
    public Iterator<? extends ParseTree> visitProductNameKeyValue(ProductNameKeyValueContext ctx) {
        switch (name) {
            case "key":
                return Collections.singletonList((ParserRuleContext) ctx.key).iterator();
            case "value":
                List<? extends ParserRuleContext> children = ctx.multipleWords();
                if (!children.isEmpty()) {
                    return children.iterator();
                }

                children = ctx.keyValueProductVersionName();
                if (!children.isEmpty()) {
                    return children.iterator();
                }

                children = ctx.siteUrl();
                if (!children.isEmpty()) {
                    return children.iterator();
                }

                children = ctx.emailAddress();
                if (!children.isEmpty()) {
                    return children.iterator();
                }

                children = ctx.uuId();
                return children.iterator();
            default:
                return getChildrenByName(ctx);
        }
    }
This visitor will return the list of requested child nodes
analyzer/src/main/java/nl/basjes/parse/useragent/analyze/treewalker/steps/walk/stepdown/UserAgentGetChildrenVisitor.java