Fix the assertion failure with inserting node contains child which has id into the document

Fix: #2630