static boolean serialize(StringBuilder destination, SameElementItem item, boolean includeField) {
            if (includeField) {
                destination.append(normalizeIndexName(item.getFieldName())).append(" contains ");
            }

            destination.append(SAME_ELEMENT).append('(');
            for (int i = 0; i < item.getItemCount(); ++i) {
                if (i > 0) {
                    destination.append(", ");
                }
                Item current = item.getItem(i);
                if (current instanceof WordItem) {
                    new WordSerializer().serialize(destination, (WordItem)current);
                } else if (current instanceof RangeItem) {
                    new RangeSerializer().serialize(destination, (RangeItem)current);
                } else if (current instanceof IntItem) {
                    new NumberSerializer().serialize(destination, (IntItem)current);
                } else if (current instanceof FuzzyItem) {
                    new FuzzySerializer().serialize(destination, (FuzzyItem)current);
                } else if (current instanceof BoolItem) {
                    new BoolSerializer().serialize(destination, (BoolItem)current);
                } else if (current instanceof GeoLocationItem) {
                    new GeoLocationSerializer().serialize(destination, (GeoLocationItem)current);
                } else if (current instanceof RegExpItem) {
                    new RegExpSerializer().serialize(destination, (RegExpItem)current);
                } else if (current instanceof WordAlternativesItem) {
                    new WordAlternativesSerializer().serialize(destination, (WordAlternativesItem)current);
                } else {
                    throw new IllegalArgumentException("Serializing of " + current.getClass().getSimpleName() +
                                                       " in same_element is not implemented, please report this as a bug.");
                }
            }
            destination.append(')');

            return false;
        }
Serialize Vespa query trees to YQL+ strings.

@author Steinar Knutsen
container-search/src/main/java/com/yahoo/search/yql/VespaSerializer.java