This might be more efficient as `elem._2.iterator.map(x => (elem._1, x).asInstanceOf[P])`; it avoids copying the whole ArrayBuffer