public TreePath[] getExpandedDescendants(TreePath parent) {
        assert SwingUtilities.isEventDispatchThread();
        TreePath[] result = new TreePath[0];
	if(isExpanded(parent)) {
            TreePath path;
            List<TreePath> results = null;

            Enumeration<TreePath> tpe = layout.getVisiblePathsFrom(parent);
            if (tpe != null) {
                while (tpe.hasMoreElements()) {
                    path = tpe.nextElement();
                    // Add the path if it is expanded, a descendant of parent,
                    // and it is visible (all parents expanded). This is rather
                    // expensive!
                    if (path != parent &&
                        layout.isExpanded(path) &&
                        parent.isDescendant(path)) {
                        
                        if (results == null) {
                            results = new ArrayList<TreePath>();
                        }
                        results.add (path);
                    }
                }
                if (results != null) {
                    result = results.toArray(result);
                }
            }
        }
        return result;
    }