Fixed error involving cycles of size one (nodes that depend on themselves) and added a test case to check for correct handling of this situation.