def Child(tpe, criterion):
    """
    A criterion used to search for records by applying a filter on their children using a criterion. For example
    
    * search for cases having file observables
    * search for cases having a specific ip observable

    Arguments:
        tpe (str): class name of the child: `case_task`, `case_artifact`...
        criterion (Any): Any criterion defined by functions from the query module

    Returns:
        dict: JSON repsentation of the criterion
            ```python
            # Query to search for cases having iocs of type file
            query = Child('case_artifact', And(
                Eq('dataType', 'file'),
                Eq('ioc', True)
            ))
            ```
            produces
            ```json
            {
                "_child": {
                    "_type": "case_artifact",
                    "_query": {
                        "_and": [
                            [
                                {
                                    "_field": "dataType",
                                    "_value": "file"
                                },
                                {
                                    "_field": "ioc",
                                    "_value": true
                                }
                            ]
                        ]
                    }
                }
            }
            ```
    """
    return {'_child': {'_type': tpe, '_query': criterion}}