Set<ElementExpression> elementExpressions = matchExpression.getDelegate().vertexSet();
if( elementExpressions.size() != 1 )
throw new IllegalStateException( "may not search multiple matches against multi-node expression: " + matchExpression );
ElementExpression expression = Util.getFirst( elementExpressions );
if( expression.getCapture() != ElementCapture.Primary )
throw new IllegalStateException( "capture on expression must be Primary: " + expression );
Set<FlowElement> foundElements = new LinkedHashSet<>();
// no evidence elementGraph.vertexSet().iterator(); is faster without modifying jgrapht
Iterator<FlowElement> iterator = SearchOrder.getNodeIterator( matchExpression.getSearchOrder(), elementGraph );
while( iterator.hasNext() )
{
FlowElement flowElement = iterator.next();
if( exclusions.contains( flowElement ) )
continue;
if( expression.applies( plannerContext, elementGraph, flowElement ) )
foundElements.add( flowElement );
}
// we are only capturing Primary distinguished elements
return new Match( matchExpression, elementGraph, null, foundElements, Collections.<Scope>emptySet() )