The second solution checks after each step if Kara stands next to a tree (state "tree?"). If there is no tree next to Kara, he executes the next step (state "walk"). If there is a tree, Kara changes into the state "wait", which is marked as a barrier state.

This solution synchronizes the Karas using barrier states. This makes the solution a bit more complex, but separates it completly from the world.