human
I wrote the below code

    def parse_aggregation_stage(d, key, value):
        for (st_key, st_value) in d.items():
            if isinstance(st_value, dict):
                parse_aggregation_stage(st_value, key, value)
            if (key == st_value):
                d[st_key] = value
    response = {}
    documents = []
    req = parse_request(resource)
    req_pipeline = copy.deepcopy(pipeline)
    if req.aggregation:
        try:
            query = json.loads(req.aggregation)
        except ValueError:
            abort(400, description='Aggregation    query    could    not    be    parsed.')
        for (key, value) in query.items():
            if (key[0] != '$'):
                pass
            for stage in req_pipeline:
                parse_aggregation_stage(stage, key, value)
    if (req.max_results > 1):
        limit = {'$limit': req.max_results}
        skip = {'$skip': ((req.page - 1) * req.max_results)}
        req_pipeline.append(skip)
        req_pipeline.append(limit)
    cursor = app.data.aggregate(resource, req_pipeline, options)
    for document in cursor:
        documents.append(document)
    response[config.ITEMS] = documents
    return (response, None, None, 200, [])

What's a good function header?

Here's a good function header?
assistant
#Here's a good function header.

def _perform_aggregation(resource, pipeline, options):