Implement dictionaryByOccurrences