I got the similar answer here but I was looking for something opposite of this, so I am taking help from this answer to explain my issue:
[Process JSON to create the hierarchical relationship](https://stackoverflow.com/questions/50490287/process-json-to-create-the-hierarchical-relationship)

So, I have a raw data something like this:

```
{
  "my_data": [
      {
          "name": "bugs_db",
          "type": "database",
          "children": [
              {
                  "name": "oss",
                  "type": "ui"
              },
              {
                  "name": "dashboard",
                  "type": "ui"
              },
              {
                  "name": "dev-dash",
                  "type": "ui"
              }
          ]
      },
      {
          "name": "oss",
          "type": "ui",
          "children": [
              {
                  "name": "active-directory",
                  "type": "nfs"
              },
              {
                  "name": "passive-directory",
                  "type": "FAT32"
              },
              {
                "name": "jira_db",
                "kind": "database"
              }
          ]
      },
      {
          "name": "jira_db",
          "type": "database",
          "children": [
            {
              "name": "oss",
              "kind": "ui"
            },
            {
              "name": "something",
              "kind": "ui"
            }
          ]
      },
      {
          "name": "active_directory",
          "type": "nfs",
          "children": []
      }
  ]
}

```

I need to process above data to list all the parents for a child.. for exa., if I select "name" = "oss", then the hierarchical relationship should be like this:

```
{
  "name": "oss",
   "type": "ui",
   "parents": [
     {
        "name": "bugs_db",
        "type": "database",
        "parents": [
        ]
     },
     {
       "name": "jira_db",
       "type": "database"
     }
   ]
}

```

Also there can be some circular relationship.. eg. oss child of bugs\_db and bugs\_db also child of oss.. in such case just skip further and add key "circular": true to the parent object. I think I can try processing using for loops and achieve this.. but I am looking for some similar solution suggested here: <https://stackoverflow.com/a/50491255>