Self (final boolean strict, final ElementPattern<? extends ParentType> @NotNull ... patterns) { return with(new PatternCondition<T>("insideSequence") { @Override public boolean accepts(final @NotNull T t, final ProcessingContext context) { int i = 0; ParentType element = strict ? getParent(t) : t; while (element != null && i < patterns.length) { for (int j = i; j < patterns.length; j++) { if (patterns[j].accepts(element, context)) { if (i != j) return false; i++; break; } } element = getParent(element); } return true; } }); }