PsiElement (@NotNull PsiReference ref) { if (ref instanceof PsiPolyVariantReference) { for (ResolveResult result : ((PsiPolyVariantReference)ref).multiResolve(false)) { if (!result.isValidResult()) { return null; } } } return ref.resolve(); }