const data = [{ id: 1, children: [{ id: 2, children: [{ id: 3, }, { id: 4, }], }], }, { id: 5, children: [{ id: 6, }], }]; let nodes = []; function getParentNodes(id, tree) { _getParentNodes([], id, tree); return nodes; } function _getParentNodes(his