地图优化的嵌套范围循环

I am trying to collect all X and Y values from a Struct field and place Y values that belong to the same X value in a map, but it is nested 3 levels down.

Currently, I am using the following code:

topClasses := make([]TopClass, 0)
// populate topClasses Slice here

KeyValueMap := make(map[int][]int)   

for _, nestedClass := range topClasses {
    for _, nestedItem := range nestedClass.nestedList {
        for _, value := range nestedItem.Values {
            if _, found := KeyValueMap[value.X]; !found {
                KeyValueMap[value.X] = []int{value.Y}
            } else {
                KeyValueMap[value.X] = append(KeyValueMap[value.X], value.Y)
            }
        }
    }
}

Below is how the Structs are implemented:

type TopClass struct {
    nestedList []ListClass
}

type ListClass struct {
    Values []Value       
}

type Value struct {
    X int
    Y float64
}

Is there a more efficient way to do this using goroutines, channels, and/or waitgroups, etc. even though I am working with maps?

The following code eliminates an extra map lookup in the case where the key is already present. It's also shorter.

KeyValueMap := make(map[int][]int)

for _, nestedClass := range topClass {
    for _, nestedItem := range nestedClass.nestedList {
        for _, value := range nestedItem.Values {
            KeyValueMap[value.X] = append(KeyValueMap[value.X], value.Y)
        }
    }
}