'Returns an iterator of:
{fields: <fields>, count: <number of occurrence or sum of sumfields>,
collected: <collected fields>}.
WARNING/FIXME: this mutates the query'

def top(self, query, fields, collect=None, sumfields=None):

    collect = (collect or [])
    sumfields = (sumfields or [])
    for flist in (fields, collect, sumfields):
        for i in range(len(flist)):
            if flist[i].startswith('link.'):
                flist[i] = flist[i].replace('flow.', 'link.')
            if ('.' not in flist[i]):
                flist[i] = ('link.%s' % flist[i])
            flist[i] = '.'.join((cypher_escape(elt) for elt in flist[i].split('.')))
    cy_fields = ('[%s]' % ',    '.join(fields))
    cy_collect = ('[%s]' % ',    '.join(collect))
    cy_sumfields = ('SUM(%s)' % '    +    '.join(sumfields))
    query.add_clause(('WITH    src.elt    as    src,    link.elt    as    link,    dst.elt    as    dst\nWITH    %s    as    fields,    %s    as    count,    %s    as    collected' % (cy_fields, ('COUNT(*)' if (not sumfields) else cy_sumfields), ('NULL' if (not collect) else ('COLLECT(DISTINCT    %s)' % cy_collect)))))
    query.ret = 'RETURN    fields,    count,    collected'
    query.orderby = 'ORDER    BY    count    DESC'
    top = self._cursor2top(self.run(query))
    return top
