Fixed error in tree conversion including cycles.