This is simpler as `if course_updates and getattr(course_updates, 'items', None):`