Hotfix: TypeError: object of type 'dict_itemiterator' has no len() (#2167)
Hotfix: TypeError: object of type 'dict_itemiterator' has no len() (#2167)

* Hotfix: TypeError: object of type 'dict_itemiterator' has no len()

* Avoid looping over items 2x

Co-authored-by: Grabowski <711c73f64afdce07b7e38039a96d2224209e9a6c@crawlinski.com>
dpkp/kafka-python,DataDog/kafka-python,ohmu/kafka-python,ohmu/kafka-python,dpkp/kafka-python