question: public static void appendChild ( Node parent , Node child ) { Document ownerDoc = getOwnerDocument ( parent ) ; if ( child . getOwnerDocument ( ) != ownerDoc ) { parent . appendChild ( ownerDoc . importNode ( child , true ) ) ; } else { parent . appendChild ( child ) ; } }
target:  Checks if child element has same owner document before appending to the parent, and imports it to the parent's document if necessary.