I am trying to retrieve all the names of objects in a nested object tree/structure.

```
var testObj = {
      "name": "testObj",
      "version": "0.1.1",
      "dependencies": {
        "nameLvl1-1": {
          "version": "0.3.7",
          "dependencies": {
            "nameLvl2": {
              "version": "0.0.2"
            }
          }
        },
        "nameLvl1-2": {
          "version": "1.2.6"
        }
      }
    }

```

Currently I am iterating through the structure using recursion, but when I try to 'capture' the object names within the nested structure it returns 'undefined'

This is what I have currently:

```
const versionKeys2 = (obj) => {
  const result = []
  Object.keys(obj).forEach(x => {
    const key = x;
    const value = obj[x];
    if (key === 'version') {
      console.log(`${key} as key, ${obj[key]} as value, ${obj.name} as obj`)
      result.push(`${obj.name}@${obj[key]}`)
    }
    if (typeof value === 'object') {
      result.push(versionKeys2(value))
    }
  })
  return result
}

```

As an example which is logged to the console:

```
version as key, 0.3.7 as value, undefined as obj

```

For the first level it returns the name, but one past the level, into a nested object the '${obj.name}' returns undefined. Anyone know to address the object name beyond the first level?

EDIT: Expected results based on template literal string would look like so -- `[["dependencies"@"0.3.7"],["nameLvl1-1"@"0.3.7"],["nameLvl2"@"0.0.2"],["nameLvl1-2"@"1.2.6"]]`