public static XmlTag createChildTag(@NotNull XmlTag xmlTag,
                                      @NotNull String localName,
                                      @Nullable String namespace,
                                      @Nullable String bodyText,
                                      boolean enforceNamespacesDeep,
                                      @NotNull Function<String, XmlTag> tagFromTextFactory) {
    String qname;
    final String prefix = xmlTag.getPrefixByNamespace(namespace);
    if (prefix != null && !prefix.isEmpty()) {
      qname = prefix + ":" + localName;
    }
    else {
      qname = localName;
    }
    try {
      String tagStart = qname + (!StringUtil.isEmpty(namespace) && xmlTag.getPrefixByNamespace(namespace) == null &&
                                 !(StringUtil.isEmpty(xmlTag.getNamespacePrefix()) && namespace.equals(xmlTag.getNamespace()))
                                 ? " xmlns=\"" + namespace + "\""
                                 : "");
      XmlTag retTag;
      if (bodyText != null) {
        retTag = tagFromTextFactory.apply("<" + tagStart + ">" + bodyText + "</" + qname + ">");
        if (enforceNamespacesDeep) {
          retTag.acceptChildren(new XmlRecursiveElementVisitor() {
            @Override
            public void visitXmlTag(@NotNull XmlTag tag) {
              final String namespacePrefix = tag.getNamespacePrefix();
              if (namespacePrefix.isEmpty()) {
                String qname;
                if (prefix != null && !prefix.isEmpty()) {
                  qname = prefix + ":" + tag.getLocalName();
                }
                else {
                  qname = tag.getLocalName();
                }
                try {
                  tag.setName(qname);
                }
                catch (IncorrectOperationException e) {
                  LOG.error(e);
                }
              }
              super.visitXmlTag(tag);
            }
          });
        }
      }
      else {
        retTag = tagFromTextFactory.apply("<" + tagStart + "/>");
      }
      return retTag;
    }
    catch (IncorrectOperationException e) {
      LOG.error(e);
    }
    return null;
  }
public static XmlTag createChildTag(@NotNull XmlTag xmlTag,
                                      @NotNull String localName,
                                      @Nullable String namespace,
                                      @Nullable String bodyText,
                                      boolean enforceNamespacesDeep,
                                      @NotNull Function<String, XmlTag> tagFromTextFactory)