Mongo: Avoid dereferencing a null cursor