Since this pattern occurs in all of these, how about a utility ``contains_only(container, type)``?