PsiElement (PsiReference reference) { final PsiElement element = reference.resolve(); if (element != null) { return element; } if (reference instanceof PsiPolyVariantReference) { final ResolveResult[] results = ((PsiPolyVariantReference)reference).multiResolve(false); for (ResolveResult result : results) { if (result.isValidResult() && result.getElement() instanceof XsltElement) { return result.getElement(); } } } return null; }