'Analyze incoming XML stanzas and convert them into stanza
objects if applicable and queue stream events to be processed
by matching handlers.
:param xml: The :class:`~sleekxmpp.xmlstream.stanzabase.ElementBase`
stanza to analyze.'

def __spawn_event(self, xml):

    xml = self.incoming_filter(xml)
    stanza = self._build_stanza(xml)
    for filter in self.__filters[u'in']:
        if (stanza is not None):
            stanza = filter(stanza)
    if (stanza is None):
        return
    log.debug(u'RECV:    %s', stanza)
    unhandled = True
    matched_handlers = [h for h in self.__handlers if h.match(stanza)]
    for handler in matched_handlers:
        if (len(matched_handlers) > 1):
            stanza_copy = copy.copy(stanza)
        else:
            stanza_copy = stanza
        handler.prerun(stanza_copy)
        self.event_queue.put((u'stanza', handler, stanza_copy))
        try:
            if handler.check_delete():
                self.__handlers.remove(handler)
        except:
            pass
        unhandled = False
    if unhandled:
        stanza.unhandled()
