[COLLECTIONS-540] Duplication of code in CollectionUtils