How to find duplicate values in object and push in array to create distinct array of objects in Angular8

I am getting below response from API, but i want to format it for iteration to reach the correct values.

In below objects, i am getting column makeLineName and based on this column, i want to create one types array and push whole object as it is on types array.

Suppose for ex – In below response, We have 2 objects for “makeLineName”:”Red”, So i want to create one types array and push all object inside types array whose matching makeLineName = Red. Thats it.

const data = [{
"makeLineName":"Red",
"country":"Germany",
"processTypeId":"3",
"processTechType":"Batch & crunch"
},
{
"makeLineName":"Red",
"country":"Germany",
"processTypeId":"3",
"processTechType":"Batch"
},
{
"makeLineName":"Blue",
"country":"India",
"processTypeId":"3",
"processTechType":"Continues"
}
];

Expected Output

const data = [{
"makeLineName":"Red",
"country":"Germany",
types :[{
"makeLineName":"Red",
"processTypeId":"3",
"country":"Germany",
"processTechType":"Batch & crunch"
},
{
"makeLineName":"Red",
"processTypeId":"3",
"country":"Germany",
"processTechType":"Batch"
}]
},
{
"makeLineName":"Blue",
"country":"India"
types :[{
"makeLineName":"Blue",
"country":"India",
"processTypeId":"3",
"processTechType":"Continues"
}

}];

I did below code, it was working fine, but it is creating many nested arrays for types and because of this i am facing issue in iterating with loop to get the perfect value of types array.

getMakeLineMasterData() {
    const data = {
      data1: 'India'
    };  
    this.testfile.getWork(data).pipe(map(data => this.processData(data))).subscribe((resp: any) => {
      if (resp) {
        console.log(this.dataSource, "resp");
      }
    });
  }
  processData(data: any) {
    let mappedData = [];
    for (const item of data) {
      const mitem = mappedData.find(obj => obj.makeLineName == item.makeLineName);
      if (mitem) {
        mitem['types'].push(item);
      } else {
        let newItem = item;
        newItem['types'] = [item];
        mappedData.push(newItem);
      }
    }   
    return mappedData;
  }

Right now my code is working and returning data but it is creating many nested arrays for types inside and inside likewise..
Can anyone help me to make it proper as per my expected output.