Loop to create a new column

Hi,

I have created the attached workflow which is basically building the hierarchical chain for each of the employees.

I wanted to do this using a loop as the number of iterations is not fixed in the real life example.

In a perfect world I want to stop the iteration for each employee once the CEO (nr.10 in the example attached) is already present in the chain.

Any suggestion?

loop test.knwf