public static TreePath createTreePathToRoot ( TreeModel treeModel , Object node ) { List < Object > nodes = new ArrayList < Object > ( ) ; nodes . add ( node ) ; Object current = node ; while ( true ) { Object parent = getParent ( treeModel , current ) ; if ( parent == null ) { break ; } nodes . add ( 0 , parent ) ; current = parent ; } TreePath treePath = new TreePath ( nodes . toArray ( ) ) ; return treePath ; }
Returns the tree path from the given node to the root in the given tree model