def METHOD_NAME():
    """Create a nested filter for document identifiers.
    :return: Function that returns a nested query to document containing
             specified identifiers
    """
    def _build_nested_identifier_query(identifier):
        # Next regexp capture identifier type and value. For example :
        #  * "123456789" --> id_value=123456789
        #  * "(bf:Isbn)123456789 --> id_type=bf:Isbn, id_value=123456789
        #  * "(bf:Local)kw(2) --> id_type=bf:Local, id_value=kw(2)
        regexp = re.compile(r'^(\((?P<id_type>[\w\d:]+)\))?(?P<id_value>.*)$')
        matches = re.match(regexp, identifier)
        criteria = Q('wildcard', nested_identifiers__value=matches['id_value'])
        if matches['id_type']:
            criteria &= Q('match', nested_identifiers__type=matches['id_type'])
        return Q('nested', path='nested_identifiers', query=criteria)
    def inner(identifiers):
        queries = [
            _build_nested_identifier_query(identifier)
            for identifier in identifiers
        ]
        return Q('bool', should=queries)
    return inner