I have array with data:
const data = [
{ id: 1, type: 'type 1' },
{ id: 2, type: 'type 2', subtype: 'subtype 2' },
{ id: 3, type: 'type 2', subtype: 'subtype 3' },
{ id: 4, type: 'type 2', subtype: 'subtype 4' },
{ id: 5, type: 'type 3', subtype: 'subtype 3' },
];
And I need to build the tree like this:
type 1
type 2
subtype 2
subtype 3
subtype 4
type 3
subtype 3