Saring javascript pohon array objek

const filterData = (data : any, id : any) => data.filter((o : any) => {
  if (o.children) o.children = filterData(o.children, id);
  return o.id != id
})

const searchResult = filterData(tasks, "Task 1")
Daniel Kristoffersen