Lookup the handler for the giving idetifier (descriptor_type) and role.
        In case it was not found return the default.

        Logic goes as follows:
         - First try to find exact match for identifier and role,
         - Try to find match for identifier and role=None,
         - Return default handler.

def query_handler(cls, identifier, role=None):
        '''
        Lookup the handler for the giving idetifier (descriptor_type) and role.
        In case it was not found return the default.

        Logic goes as follows:
         - First try to find exact match for identifier and role,
         - Try to find match for identifier and role=None,
         - Return default handler.
        '''
        key = cls._key_for(identifier, role)
        handler = cls._handlers.get(key, None)
        if handler is None:
            default_for_identifier = cls._key_for(identifier, None)
            handler = cls._handlers.get(default_for_identifier,
                                        cls._handlers['_default'])
        return handler