 						}
 					"""
 
-					if cycledNodes.has node
-						"""
-							while (runtime.isAlive()) _#{node}: {
-								#{randomCode}
-							}
-						"""
-					else
-						randomCode
+					wrapIfLooping cycledNodes, node, randomCode
+
 				when 2
 					branch0 = df neighbours[0].to, newStack
 					branch1 = df neighbours[1].to, newStack


assemble = (graph) ->
	cycledNodes = new Set

	df = (node, stack) ->
		# for debugging only

						}
					"""

					wrapIfLooping cycledNodes, node, selectCode

				when 1
					branch = df neighbours[0].to, newStack

