export function getTree(data, id, parent) {
    let map = {};
    let tree = []
    if (data) {
        for (let i = 0; i < data.length; i++) {
            let item = data[i]
            if (item.parent === null) {
                tree.push(item)
            }
            map[item[id]] = item
        }
        for (let i = 0; i < data.length; i++) {
            let child = data[i];
            let parentList = (map[child[parent]])

            if (parentList) {
                if (!parentList['children']) {
                    parentList['children'] = []
                }
                parentList.children.push(child)
            }
        }
    }
    return tree
}