is it possible that toMap and distinct() will accomplish the same thing? I don't know enough about Scala internals, but it seems if you don't call distinct, the duplicate key value will just be eliminated in the toMap call.