<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _remove_unexpected_query_parameters(schema, req):
 """Remove unexpected properties from the req.GET."""

    additional_properties = schema.get('addtionalProperties', True)

    if additional_properties:
        pattern_regexes = []

        patterns = schema.get('patternProperties', None)
        if patterns:
            for regex in patterns:
                pattern_regexes.append(re.compile(regex))

        for param in set(req.GET.keys()):
            if param not in schema['properties'].keys():
                if not (list(regex for regex in pattern_regexes if
                             regex.match(param))):
                    del req.GET[param]