private static int getHeaderRank(final XmlTag header) {
    if (HGROUP_ELEMENT.equalsIgnoreCase(header.getLocalName())) {
      int minIndex = HEADER_ELEMENTS.length;

      for (XmlTag subTag : header.getSubTags()) {
        int index = ArrayUtilRt.indexOf(HEADER_ELEMENTS, StringUtil.toLowerCase(subTag.getLocalName()), 0, HEADER_ELEMENTS.length);
        if (index < minIndex) {
          minIndex = index;
          if (minIndex == 0) break;
        }
      }

      if (minIndex == HEADER_ELEMENTS.length) {
        // no headers is equivalent to <h1>
        minIndex = 0;
      }

      return minIndex + 1;
    }

    int index = ArrayUtilRt.indexOf(HEADER_ELEMENTS, StringUtil.toLowerCase(header.getLocalName()), 0, HEADER_ELEMENTS.length);
    if (index < 0) throw new IllegalArgumentException(header.getName());
    return index + 1;
  }
private static int getHeaderRank(final XmlTag header)