Implemented Tarjan's algorithm for removing dead-end nodes.

 - Previous two pass algorithm didn't work in all cases.
 - Tarjan's is a single pass, and ~2x the speed.