'Pop one search term from the beginning of C{query} (possibly more than
one element) and return whether it matches the given message.
@param query: A list representing the parsed form of the search query.
@param msgId: The sequence number of the message being checked.
@param msg: The message being checked.
@param lastSequenceId: The highest sequence number of any message in
the mailbox being searched.
@param lastMessageId: The highest UID of any message in the mailbox
being searched.
@return: Boolean indicating whether the query term matched the message.'

def _singleSearchStep(self, query, msgId, msg, lastSequenceId, lastMessageId):

    q = query.pop(0)
    if isinstance(q, list):
        if (not self._searchFilter(q, msgId, msg, lastSequenceId, lastMessageId)):
            return False
    else:
        c = q.upper()
        if (not c[:1].isalpha()):
            messageSet = parseIdList(c, lastSequenceId)
            return (msgId in messageSet)
        else:
            f = getattr(self, ('search_' + nativeString(c)), None)
            if (f is None):
                raise IllegalQueryError(('Invalid    search    command    %s' % nativeString(c)))
            if (c in self._requiresLastMessageInfo):
                result = f(query, msgId, msg, (lastSequenceId, lastMessageId))
            else:
                result = f(query, msgId, msg)
            if (not result):
                return False
    return True
