var array = [
{
"name": "test",
"id": "1",
"root_id": "33"
},
{
"name": "test",
"id": "2",
"root_id": "33"
},
{
"name": "test",
"id": "70",
"root_id": "90"
},
{
"name": "test",
"id": "55",
"root_id": "90"
},
{
"name": "test",
"id": "33",
"root_id": "55"
},
]
const roots = arr.filter((n, i, a) => !a.some(m => m.id === n.root_id));
const roots = arr.filter(function(n) {
return !this.has(n.root_id);
}, new Set(arr.map(n => n.id)));
// проиндексируем по ключам
const [rootIndex, idIndex] = array.reduce(([roots, ids], obj) => {
(roots[obj.root_id] ??= []).push(obj);
ids[obj.id] = obj;
return [roots, ids];
}, [{}, {}]);
// и найдем по нему нужные объекты:
const objectsWithoutExistingParent = Object.keys(rootIndex).filter(key => !idIndex.hasOwnProperty(key)).flatMap(key => rootIndex[key]);
console.log(objectsWithoutExistingParent);