replaceFieldsInList(groupedFields, old2newFields);
//replace the use of old fields in 'groupby' by the new projected
replaceFieldsInList(groupByFields, old2newFields);
//replace the use of old fields in 'selected' by the new projected
replaceFieldsInList(selectfields, old2newFields);
return new Nest((QueryTreeField[]) groupedFields
.toArray(new QueryTreeField[groupedFields.size()]),
"grouped_fields", (QueryTreeField[]) groupByFields
.toArray(new QueryTreeField[groupByFields
.size()]), "aggregate_node");
//The nest becomes the top node, selected field will add on it