User Notes:

What leads you to believe that the first branch of the if statement is impossible? What if another script running concurrently has inserted a document with that ID in between the call to remove and call to get?