insertBefore() is able to work on nodes from different documents, so on adding child or sibling it's possible that libxml2 switches doc pointer for a node, we need to update refcounts to cover that case.