private static void expandChildren(BaseComponent parent, int depth) {
        if (parent == null || depth <= 0) {
            return;
        }

        depth--;

        for (Object object : parent.getChildren()) {
            Treenode item = (Treenode) object;
            item.setCollapsed(depth <= 0);
            expandChildren(item, depth);
        }
    }
private static void expandChildren ( BaseComponent parent , int depth ) { if ( parent == null || depth <= 0 ) { return ; } depth -- ; for ( Object object : parent . getChildren ( ) ) { Treenode item = ( Treenode ) object ; item . setCollapsed ( depth <= 0 ) ; expandChildren ( item , depth ) ; } }
Expand / collapse tree children to specified depth.

@param parent Tree children whose tree items are to be expanded / collapsed.
@param depth Expand tree items to this depth. Tree items below this depth are collapsed.