Fixed bug

Fixed bug where not all cycles were detected when some nodes branched
into several different nodes.