def Parent(tpe, criterion):
    """
    A criterion used to search for records by filtering the parents using a criterion. For example
    
    * search for observables of TLP:RED cases
    * search for logs of tasks called 'Communication'

    Arguments:
        tpe (str): class name of the parent: `case`, `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 tasks belonging to open cases with TLP=RED
            query = Parent('case', And(
                Eq('status', 'Open'),
                Eq('tlp', 3)
            ))
            ```
            produces
            ```json
            {
                "_parent": {
                    "_type": "case",
                    "_query": {
                        "_and": [
                            [
                                {
                                    "_field": "status",
                                    "_value": "Open"
                                },
                                {
                                    "_field": "tlp",
                                    "_value": 3
                                }
                            ]
                        ]
                    }
                }
            }
            ```
    """
    return {'_parent': {'_type': tpe, '_query': criterion}}