The association to the parent document of the embedded would still be in the UnitOfWork but I don't think that is a problem. To undo the scheduled removal we just need to remove the object from the documentDeletions array. I think removing the if ( ! $class->isEmbeddedDocument) { is the correct fix here.