0
You may expand your input array recursively, like that:
const src = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],
getTree = (inputData, parent=null, idx=0) => {
const name = (!parent ? 'node_0' : parent+(idx+1)),
halfLength = inputData.length/2,
...