docs: public static Presence parsePresence(XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
          ParserUtils.assertAtStartTag(parser);
          final int initialDepth = parser.getDepth();
          XmlEnvironment presenceXmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment);
  
          Presence.Type type = Presence.Type.available;
          String typeString = parser.getAttributeValue("", "type");
          if (typeString != null && !typeString.equals("")) {
              type = Presence.Type.fromString(typeString);
          }
          Presence presence = new Presence(type);
          presence.setTo(ParserUtils.getJidAttribute(parser, "to"));
          presence.setFrom(ParserUtils.getJidAttribute(parser, "from"));
          presence.setStanzaId(parser.getAttributeValue("", "id"));
  
          String language = ParserUtils.getXmlLang(parser);
          if (language != null && !"".equals(language.trim())) {
          // CHECKSTYLE:OFF
          	presence.setLanguage(language);
          // CHECKSTYLE:ON
          }
  
          // Parse sub-elements
          outerloop: while (true) {
              int eventType = parser.next();
              switch (eventType) {
              case XmlPullParser.START_TAG:
                  String elementName = parser.getName();
                  String namespace = parser.getNamespace();
                  switch (elementName) {
                  case "status":
                      presence.setStatus(parser.nextText());
                      break;
                  case "priority":
                      int priority = Integer.parseInt(parser.nextText());
                      presence.setPriority(priority);
                      break;
                  case "show":
                      String modeText = parser.nextText();
                      if (StringUtils.isNotEmpty(modeText)) {
                          presence.setMode(Presence.Mode.fromString(modeText));
                      } else {
                          // Some implementations send presence stanzas with a
                          // '<show />' element, which is a invalid XMPP presence
                          // stanza according to RFC 6121 4.7.2.1
                          LOGGER.warning("Empty or null mode text in presence show element form "
                                          + presence.getFrom()
                                          + " with id '"
                                          + presence.getStanzaId()
                                          + "' which is invalid according to RFC6121 4.7.2.1");
                      }
                      break;
                  case "error":
                      presence.setError(parseError(parser, presenceXmlEnvironment));
                      break;
                  default:
                  // Otherwise, it must be a packet extension.
                      // Be extra robust: Skip PacketExtensions that cause Exceptions, instead of
                      // failing completely here. See SMACK-390 for more information.
                      try {
                          PacketParserUtils.addExtensionElement(presence, parser, elementName, namespace, presenceXmlEnvironment);
                      } catch (Exception e) {
                          LOGGER.warning("Failed to parse extension element in Presence stanza: \"" + e + "\" from: '"
                                          + presence.getFrom() + " id: '" + presence.getStanzaId() + "'");
                      }
                      break;
                  }
                  break;
              case XmlPullParser.END_TAG:
                  if (parser.getDepth() == initialDepth) {
                      break outerloop;
                  }
                  break;
              }
          }
          return presence;
      }