I have created lrel connection between the changes, that show how they depend on each other, now I am looking for the way to detect and prevent loops in their dependences. It should be standard graph loop detection mechanism but I have no clue how to implement it using spell script.