const items = [{"value": "10","label": "LIMEIRA","children": []},{"value": "10-3","label": "RECEBIMENTO","children": []},{"value": "10-3-4","label": "GAVETEIRO","children": []},{"value": "10-3-4-A1","label": "A1","children": []},{"value": "10-3-4-A1-N1","label": "N1","children": []},{"value": "10-3-4-A1-N1-N2","label": "N2","children": []},{"value": "10-4","label": "MEZANINO","children": []},{"value": "10-4-4","label": "GAVETEIRO","children": []},{"value": "10-4-4-B1","label": "B1","children": []},{"value": "10-3-3","label": "PRATELEIRA","children": []},{"value": "10-3-3-C1","label": "C1","children": []},{"value": "10-3-3-C1-N1","label": "N1","children": []},{"value": "11","label": "N & C BRASIL PROCESSAMENTO DE DADOS LTDA","children": []},{"value": "11-4","label": "MEZANINO","children": []},{"value": "11-4-4","label": "GAVETEIRO","children": []},{"value": "11-4-4-A1","label": "A1","children": []},{"value": "11-4-4-A1-N2","label": "N2","children": []},{"value": "11-4-4-A1-N2-N2","label": "N2","children": []},{"value": "10-4-4-A1","label": "A1","children": []},{"value": "10-4-4-A1-N2","label": "N2","children": []},{"value": "10-4-4-A1-N2-N2","label": "N2","children": []},{"value": "11-4-4-A2","label": "A2","children": []}];
const children = [];
const map = new Map(items.map(o => [o.value, o])).set("", { children });
for (const o of items) map.get(o.value.replace(/-?[^-]+$/, "")).children.push(o);
console.log(children);