I have one array as below :

```
[
  {
    id: '97b76d27-ad1d-42f9-89e9-be8ca61dc91d',
    name: 'nokia',
    filename: '1644992710452-698281553portland_skyline.jpg',
    parent_id: 'b1132090-ad75-4f19-b449-3595ae1620c2'
  },
  {
    id: 'dc1be5de-c871-475e-b9f7-a404c9625fb9',
    name: 'realme',
    filename: '1644992710452-698281553portland_skyline.jpg',
    parent_id: '8016c51f-fcc5-44f5-8492-d90a88ecfd7a'
  },
  {
    id: 'fa542e2b-7ac2-4979-b13d-0ebf57b08ddf',
    name: 'oneplus',
    filename: '1644992710452-698281553portland_skyline.jpg',
    parent_id: '97b76d27-ad1d-42f9-89e9-be8ca61dc91d'
  },
  {
    id: '8016c51f-fcc5-44f5-8492-d90a88ecfd7a',
    name: 'Galaxy prime',
    filename: '1644992710452-698281553portland_skyline.jpg',
    parent_id: 'b1132090-ad75-4f19-b449-3595ae1620c2'
  },
  {
    id: 'e66b4903-6f5d-4311-b9c9-2efd6750a776',
    name: 'Galaxy tab',
    filename: '1645512038535-438816287Vanamo_Logo.png',
    parent_id: 'b1132090-ad75-4f19-b449-3595ae1620c2'
  },
  {
    id: 'a725e322-5c0c-4443-9ad2-9747d41b283e',
    name: 'Galaxy champ',
    filename: '1645512305563-841288453Vanamo_Logo.png',
    parent_id: 'b1132090-ad75-4f19-b449-3595ae1620c2'
  },
  {
    id: 'b1132090-ad75-4f19-b449-3595ae1620c2',
    name: 'samsung',
    filename: '1645527489139-708675878Vanamo_Logo.png',
    parent_id: null
  },
  {
    id: '49ef97df-9066-458a-9794-7798ee4d72c1',
    name: 'note 9 pro',
    filename: '1645592972776-366584498Vanamo_Logo.png',
    parent_id: '41a7aac1-1957-496a-86bb-7b53768c0a35'
  },
  {
    id: '395b595e-6b23-43ab-9cf4-eca495901c75',
    name: 'Xiomi',
    filename: '1645594875297-864602535Vanamo_Logo.png',
    parent_id: 'b1132090-ad75-4f19-b449-3595ae1620c2'
  },
  {
    id: 'daa69323-ee9e-4ff6-87f5-fd053656ba35',
    name: 'note 8',
    filename: '1645594891221-11318065Vanamo_Logo.png',
    parent_id: '395b595e-6b23-43ab-9cf4-eca495901c75'
  },
  {
    id: '0290bb2b-38ab-4d97-b3e8-5d7af471eff8',
    name: 'note 9',
    filename: '1645594910725-698567441Vanamo_Logo.png',
    parent_id: '395b595e-6b23-43ab-9cf4-eca495901c75'
  },
  {
    id: '0035b5b4-a0ae-4f00-9b0a-c8bd33d159ee',
    name: 'note 8 pro',
    filename: '1645594924778-936353966Vanamo_Logo.png',
    parent_id: 'daa69323-ee9e-4ff6-87f5-fd053656ba35'
  },
  {
    id: '40ab3cfd-52c4-4e7e-87e0-79133571c934',
    name: 'note 9 pro',
    filename: '1645594939585-660548801Vanamo_Logo.png',
    parent_id: '0290bb2b-38ab-4d97-b3e8-5d7af471eff8'
  }
]

```

If I filter array with **xiomi** id = 395b595e-6b23-43ab-9cf4-eca495901c75.

I am only able to get two child.
Because, **xiomi** id is parent\_id of **note 8** and **note 9**.

```
[
  {
    id: 'daa69323-ee9e-4ff6-87f5-fd053656ba35',
    name: 'note 8',
    filename: '1645594891221-11318065Vanamo_Logo.png',
    parent_id: '395b595e-6b23-43ab-9cf4-eca495901c75'
  },
  {
    id: '0290bb2b-38ab-4d97-b3e8-5d7af471eff8',
    name: 'note 9',
    filename: '1645594910725-698567441Vanamo_Logo.png',
    parent_id: '395b595e-6b23-43ab-9cf4-eca495901c75'
  }
]

```

but **note 8** has child **note 8 pro** and **note 9** has child **note 9 pro**.

how can I get that output?

Below is My Code :

```
let orgList = []
    childOrgs.filter((item) => {
      orgList.push({
        id : item.dataValues.id,
        name : item.dataValues.name,
        filename : item.dataValues.logo_filename,
        parent_id : item.dataValues.parent_org_id
      })
    })
    console.log('<<-- orgList -->>', orgList);
    orgList = orgList.filter((orgs)=> orgs.parent_id === org[0].dataValues.id);
    console.log('<<---- orgList ---->>', orgList);
    const result = await organizationService.deleteOrg(id);
    // fs.unlinkSync(`../../../static/${filename}`, (err) => { console.log('err -->>',err)});
    console.log("result -->> ", result);
    if (result === 1) {
      res
        .status(200)
        .json({ message: "Organization deleted successfully!", success: true });
    } else {
      res
        .status(400)
        .json({ message: "something went wrong!", success: false });
    }

```

Please help me to sort it out.
Thanks:)