How to implement tree structure in nodejs with JSON data

i have some json data from mongoDB like this:

[
  {
    "_id": {
      "$oid": "1"
    },
    "name": "A Inc",
    "children": [
       {"$oid": "1"},{"$oid": "2"}],
    "kind": "Organisation"
  },
  {
    "_id": {
      "$oid": "2"
    },
    "name": "ACS",
    "children": [{"$oid": "2"}],
    "kind": "Organisation"
  },
  {
    "_id": {
      "$oid": "3"
    },
    "name": "ABC Inc",
    "children": [],
    "kind": "Organisation"
  },
   {
    "_id": {
      "$oid": "5"
    },
    "name": "Disney",
    "children": [some other ids],
    "kind": "Channel"
  },
...
]

I don’t know how to create a forest or multiple root tree, ideally, I want generate a data structure that using resursive method to link all those data together, But I’m facing a problem which is sometimes it will have duplicated layers, like

enter image description here

Some of the grand children still in children, I want some algorithm to handle this situation, if id is in leaf layer, it won’t in upper layer, that means, each id should theoretically appear once.