private void mergeTree(Block targetTree, Block sourceTree)
    {
        for (Block block : sourceTree.getChildren()) {
            // Check if the current block exists in the target tree at the same place in the tree
            int pos = indexOf(targetTree.getChildren(), block);
            if (pos > -1) {
                Block foundBlock = targetTree.getChildren().get(pos);
                mergeTree(foundBlock, block);
            } else {
                targetTree.addChild(block);
            }
        }
    }
private void mergeTree ( Block targetTree , Block sourceTree ) { for ( Block block : sourceTree . getChildren ( ) ) { int pos = indexOf ( targetTree . getChildren ( ) , block ) ; if ( pos > - 1 ) { Block foundBlock = targetTree . getChildren ( ) . get ( pos ) ; mergeTree ( foundBlock , block ) ; } else { targetTree . addChild ( block ) ; } } }
Merged two XDOM trees.

@param targetTree the tree to merge into
@param sourceTree the tree to merge