Self (final ElementPattern<? extends PsiElement> ancestor) { return with(new PatternCondition<T>("withTreeParent") { @Override public boolean accepts(@NotNull T t, ProcessingContext context) { return ancestor.accepts(t.getParent(), context); } }); }