Self (final boolean strict, final @NotNull ElementPattern<? extends ParentType> pattern, final @NotNull ElementPattern<? extends ParentType> stopAt) { return with(new PatternCondition<T>("inside") { @Override public boolean accepts(@NotNull T t, ProcessingContext context) { ParentType element = strict ? getParent(t) : t; while (element != null) { if (stopAt.accepts(element, context)) return false; if (pattern.accepts(element, context)) return true; element = getParent(element); } return false; } }); }