题目:
You are given a binary tree with unique integer values on each node. However, the child pointers on each node may point to any other node in the tree including itself, introducing cycles into the binary tree. A cycle is defined when you can traverse back to the same node by following its descendants. Write a function that takes in the root node of the tree and prints out the cycles, if any, in the binary tree. The only operations available on each node are node.left (returns another Node or null), node.right, and node.value (returns the integer value of the node). Pseudocode is fine.
即找出有向图中的环(loop或者cycle),并且全部打印出来。
Example: http://i.imgur.com/7S5fZe5.png
cycles: [1, 2, 4], [5],