code: public static Stanza parseStanza(XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws Exception {
          ParserUtils.assertAtStartTag(parser);
          final String name = parser.getName();
          switch (name) {
          case Message.ELEMENT:
              return parseMessage(parser, outerXmlEnvironment);
          case IQ.IQ_ELEMENT:
              return parseIQ(parser, outerXmlEnvironment);
          case Presence.ELEMENT:
              return parsePresence(parser, outerXmlEnvironment);
          default:
              throw new IllegalArgumentException("Can only parse message, iq or presence, not " + name);
          }
      }
docs: Tries to parse and return either a Message, IQ or Presence stanza.
  
  connection is optional and is used to return feature-not-implemented errors for unknown IQ stanzas.
  
  @param parser
  @param outerXmlEnvironment the outer XML environment (optional).
  @return a stanza which is either a Message, IQ or Presence.
  @throws Exception