Breath first search of children before recursing

The InternalState.isChild method would check each child AND it's child
for a matching state before moving onto the next child.  In a heavily
hierarchical state structure this is very unoptimised.  Each child
should be checked before moving on to the next layer down.