I'm trying to write a method with the following signature:

```scala
def buildSumMap(minInterval:Int, mappes:SortedMap[Int, Long]):SortedMap[Int, Long] = {...}

```

Within the method I want to return a new map by applying the following pseudo-code to each
`(key:Int,value:Long)`-pair of "mappes":

```scala
If(key + minInterval > nextKey) {
    value += nextValue
}
else {
    //Forget previous key(s) and return current key with sum of all previous values
    return (key, value)
}

```

Example: If I had the source Map `((10 -> 5000), (20 -> 5000), (25 -> 7000), (40 -> 13000))` and defined a minInterval of 10, I'd expect the resulting Map:

`((10 -> 5000), (25 -> 12000), (40 -> 13000))`

I found a lot of examples for transforming keys **and** values of filtering keys and values seperately but none so far for *dropping* keys, while preserving the values.