Added None-type checks for collections in get_object_by_id