private static @Nullable XmlTag findClosestUnclosedTag(final XmlTag tag) {
    XmlTag unclosedTag = tag;
    while (unclosedTag != null) {
      final PsiElement lastChild = unclosedTag.getLastChild();
      if (isTagUnclosed(lastChild)) {
        return unclosedTag;
      }
      final XmlTag prevTag = PsiTreeUtil.getPrevSiblingOfType(unclosedTag, XmlTag.class);
      unclosedTag = prevTag != null ? prevTag : PsiTreeUtil.getParentOfType(unclosedTag, XmlTag.class);
    }
    return null;
  }
private static @Nullable XmlTag findClosestUnclosedTag(final XmlTag tag)