Added an assetion for checking the correctness of
the algorighm when there's some cyclic structure
in the root set