Tssst… that piece of code should have been removed when we got rid of bases here, kind of obvious it would break if object pointer itself is NULL! And since deleting an object clears its ID pointers in outliner tree, this fixes for free the issue of deleting several time the same object (being selected in several collections at once).