Fixed subtree cycle bug