DomElement (@Nullable final PsiElement element) { if (element == null) return null; final Project project = element.getProject(); final DomManager domManager = DomManager.getDomManager(project); final XmlAttribute attr = PsiTreeUtil.getParentOfType(element, XmlAttribute.class, false); if (attr != null) { GenericAttributeValue<?> value = domManager.getDomElement(attr); if (value != null) return value; } XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class, false); while (tag != null) { final DomElement domElement = domManager.getDomElement(tag); if(domElement != null) return domElement; tag = tag.getParentTag(); } return null; }