private static Object getChildWith ( Object node , Object userObject , BiPredicate < Object , Object > equality ) { DefaultMutableTreeNode treeNode = ( DefaultMutableTreeNode ) node ; for ( int j = 0 ; j < treeNode . getChildCount ( ) ; j ++ ) { TreeNode child = treeNode . getChildAt ( j ) ; Object childUserObject = getUserObjectFromTreeNode ( child ) ; if ( equality . test ( userObject , childUserObject ) ) { return child ; } } return null ; }
Returns the child of the given tree node that has a user object that is equal to the given one based on the given equality predicate . Assumes DefaultMutableTreeNodes .