export function buildTree(data) {
  const tree = {};

  data.forEach(item => {
    const code = item.type.code;
    const node = { icon: item.icon, id: item.id, name: item.name };

    if (!tree[code]) {
      tree[code] = { code: code, description: item.type.description, children: [node] };
    } else {
      tree[code].children.push(node);
    }
  });

  return Object.values(tree);
}
