boolean (Collection<? extends ElementPattern<?>> patterns, final PairProcessor<? super ElementPattern<?>, ? super Collection<Object>> valueProcessor) { final LinkedList<ElementPattern<?>> stack = new LinkedList<>(); for (final ElementPattern<?> next : patterns) { stack.add(next); while (!stack.isEmpty()) { final ElementPattern<?> pattern = stack.removeFirst(); final ElementPatternCondition<?> patternCondition = pattern.getCondition(); final InitialPatternCondition<?> initialCondition = patternCondition.getInitialCondition(); if (initialCondition instanceof InitialPatternConditionPlus) { ContainerUtil.addAllNotNull(stack, ((InitialPatternConditionPlus<?>)initialCondition).getPatterns()); } for (PatternCondition<?> condition : patternCondition.getConditions()) { if (condition instanceof PatternConditionPlus) { stack.add(((PatternConditionPlus<?, ?>)condition).getValuePattern()); } else if (condition instanceof ValuePatternCondition) { Collection<Object> values = ((ValuePatternCondition)condition).getValues(); if (!valueProcessor.process(next, values)) return false; } } } } return true; }