public static boolean tagIsWellFormed(XmlTag tag) {
    boolean ok = false;
    final PsiElement[] children = tag.getChildren();
    for (PsiElement child : children) {
      if (child instanceof XmlToken) {
        final IElementType tokenType = ((XmlToken)child).getTokenType();
        if (tokenType.equals(XmlTokenType.XML_EMPTY_ELEMENT_END) &&
            "/>".equals(child.getText())) {
          ok = true;
        }
        else if (tokenType.equals(XmlTokenType.XML_END_TAG_START)) {
          ok = true;
        }
      }
      else if (child instanceof OuterLanguageElement) {
        return false;
      }
    }

    return ok;
  }
public static boolean tagIsWellFormed(XmlTag tag)