Fixed bug in Tarjan's algorithm

Fixed bug where cycles would be ignored if nodes branch out into several
different nodes.