boolean (String name, PsiElement fromPlace) { JBIterable<String> typeParameters = JBIterable.generate(fromPlace, PsiElement::getContext) .takeWhile(c -> !(c instanceof PsiFile)) .filter(PsiTypeParameterListOwner.class) .flatMap(o -> Arrays.asList(o.getTypeParameters())) .map(PsiNamedElement::getName); return typeParameters.contains(name); }