I am using js and have an dynamic array of object from an response which looks like the following:

```
[
  {fromCountry: "TE", toCountry: "FE", type: "new", status: "created"},
  {fromCountry: "TE", toCountry: "FE", type: "old", status: "cold"},
  {fromCountry: "CD", toCountry: "EG", type: "used", status: "hot"},
  {fromCountry: "CD", toCountry: "EG", type: "old", status: "hot"},
  {fromCountry: "CD", toCountry: "EG", type: "old", status: "cold"}
];

```

I would like to create a new array and therefore I want to group them by fromCountry, count the fromCountry and add a nested array with the types and the value. It should look like is: 

```
[
  { name: "TE", value: 2, child: [{ name: "new", value: 1 }, { name: "old", value: 1 }]}, 
  { name: "CD", value: 3, child: [{ name: "used", value: 1}, { name: "old", value: 2 }]}
]

```

(Note: I would not like to use extra javascript libraries)

Could you help me please?