PsiElement (@NotNull PsiElement changedElement) { try { if (changedElement instanceof XmlToken && changedElement.getNode().getElementType() == XmlElementType.XML_ATTRIBUTE_VALUE_TOKEN) { final PsiElement grandParent = changedElement.getParent().getParent(); if (grandParent instanceof XmlAttribute) { if (XsltSupport.isXPathAttribute((XmlAttribute)grandParent)) { return grandParent; } } } else if (changedElement instanceof XmlTag && XsltSupport.isTemplate((XmlTag)changedElement, false)) { return changedElement; } } catch (NullPointerException e) { // sth was null } return null; }