def wrap_filter(query, prop, value):
    """
    Returns a copy of the query argumnt, wrapped in an additional
    filter requiring the property named by <prop> have a certain value.

    :param query: An Elasticsearch aggregation query dictionary.
    :param prop: The name of a filterable property.
    :param value: Value for the property that the query will match.
    :returns: Query dictionary wrapping the original query in an extra filter.
    """

    property_to_field = {
        'dataset': 'properties.content_category',
        'country': 'properties.platform_country',
        'station': 'properties.platform_id',
        'network': 'properties.instrument_name'
    }
    field = property_to_field[prop]

    wrapper = {
        'size': 0,
        'aggregations': {
            prop: {
                'filter': {
                    'match': {
                        field: value
                    }
                },
                'aggregations': query['aggregations']
            }
        }
    }

    return wrapper