Don't create cycles in tree structure. This will lead to an infinite loop or call stack overflow later. Closes: #711