factored is_collection checking into an assert function