private static void appendTextRecursively(final XmlTag tag, final StringBuilder buf, final int maximumTextLength) {
    if (buf.length() >= maximumTextLength) return;

    final String text = tag.getValue().getTrimmedText();
    if (!text.isEmpty()) {
      buf.append(text);
    }
    else {
      for (XmlTag subTag : tag.getSubTags()) {
        appendTextRecursively(subTag, buf, maximumTextLength);
      }
    }
  }
private static void appendTextRecursively(final XmlTag tag, final StringBuilder buf, final int maximumTextLength)