Fixed the assert_not_dependency to handle cycles properly