static @Nullable XmlNSDescriptor getNsDescriptor(XmlElement element) {
    final XmlElement parentThatProvidesMetaData = PsiTreeUtil
      .getParentOfType(CompletionUtilCoreImpl.getOriginalElement(element), XmlDocument.class, XmlMarkupDecl.class);

    if (parentThatProvidesMetaData instanceof XmlDocument document) {
      XmlNSDescriptor rootTagNSDescriptor = document.getRootTagNSDescriptor();
      if (rootTagNSDescriptor == null) rootTagNSDescriptor = (XmlNSDescriptor)document.getMetaData();
      return rootTagNSDescriptor;
    } else if (parentThatProvidesMetaData instanceof XmlMarkupDecl markupDecl) {
      final PsiMetaData psiMetaData = markupDecl.getMetaData();

      if (psiMetaData instanceof XmlNSDescriptor) {
        return (XmlNSDescriptor)psiMetaData;
      }
    }

    return null;
  }
static @Nullable XmlNSDescriptor getNsDescriptor(XmlElement element)