'Aggregate item attribute values (recursively over subgroups)
@param method: the aggregation method
@param key: the attribute key
@return: an S3GroupAggregate instance'

def aggregate(self, method, key):

    aggregates = self._aggregates
    if ((method, key) in aggregates):
        return aggregates[(method, key)]
    if (self.items is not None):
        values = self.get_values(key)
        aggregate = S3GroupAggregate(method, key, values)
    else:
        combine = S3GroupAggregate.aggregate
        aggregate = combine((group.aggregate(method, key) for group in self.groups))
    aggregates[(method, key)] = aggregate
    return aggregate
