When reverting history removal steps, we check that the next node or the previous node exists so we can add the removed node next to it. But we failed to check that the node was still connected to the document. closes odoo/odoo#141303 Related: odoo/enterprise#50304 Signed-off-by: David Monjoie (dmo) <dmo@odoo.com> Signed-off-by: Geelen Sébastien (sge) <sge@odoo.com>