Fixed bug in if condition, that caused wrong generation of trees.