fun TreeItem.expandTo(depth: Int) = { if (depth > 0 && this.isLeaf()) { this.isExpanded = true for(child:TreeItem in this.children) { child.expandTo(depth - 1) } } }