question: public static void mergeNodes ( TreeNode master , TreeNode slave ) { DefaultMutableTreeNode masterNode = ( DefaultMutableTreeNode ) master ; DefaultMutableTreeNode slaveNode = ( DefaultMutableTreeNode ) slave ; int masterCnt = masterNode . getChildCount ( ) ; while ( slaveNode . getChildCount ( ) > 0 ) { DefaultMutableTreeNode slaveNodeChild = ( DefaultMutableTreeNode ) slaveNode . getFirstChild ( ) ; for ( int m = 0 ; m < masterCnt ; m ++ ) { DefaultMutableTreeNode masterAtM = ( DefaultMutableTreeNode ) masterNode . getChildAt ( m ) ; if ( doCustomMerge ( slaveNodeChild , masterAtM ) ) { slaveNodeChild = null ; break ; } if ( MergeHelpUtilities . compareNames ( masterAtM , slaveNodeChild ) == 0 ) { if ( MergeHelpUtilities . haveEqualID ( masterAtM , slaveNodeChild ) ) { MergeHelpUtilities . mergeNodes ( DEFAULT_MERGE_TYPE , masterAtM , slaveNodeChild ) ; slaveNodeChild . removeFromParent ( ) ; slaveNodeChild = null ; break ; } MergeHelpUtilities . markNodes ( masterAtM , slaveNodeChild ) ; masterNode . add ( slaveNodeChild ) ; MergeHelpUtilities . mergeNodeChildren ( DEFAULT_MERGE_TYPE , slaveNodeChild ) ; slaveNodeChild = null ; break ; } } if ( slaveNodeChild != null ) { masterNode . add ( slaveNodeChild ) ; MergeHelpUtilities . mergeNodeChildren ( DEFAULT_MERGE_TYPE , slaveNodeChild ) ; } } slaveNode . removeFromParent ( ) ; slaveNode = null ; }
target:  Merge Nodes. Merge two nodes according to the merging rules of the masterNode. Each Subclass should override this implementation.