Map<ElementGraph, List<? extends ElementGraph>> levelResults = ruleResult.getLevelResults( phase.getLevel() );
for( Map.Entry<ElementGraph, List<? extends ElementGraph>> entry : levelResults.entrySet() )
{
ElementGraph parent = entry.getKey(); // null for root case
List<? extends ElementGraph> children = entry.getValue();
List<ElementGraph> results = new ArrayList<>();
for( ElementGraph child : children )
{
Transformed transformed = transformer.transform( plannerContext, child );
writeTrace( ruleResult, phase, (Rule) transformer, parent, child, transformed );
ElementGraph endGraph = transformed.getEndGraph();
if( endGraph != null )
results.add( endGraph );
else
results.add( child );