Simpler detection of circular dependency.
The new check detects a circular dependency immediately instead of bailing out after a large number of iterations.