please provide an algorithm which can transform lists provided by kastaliarbre.sql
{6301,6302} | {Presentations,OEB.global}
{6301,6302,6303} | {Presentations,OEB.global,"Order of the day"}
{6301,6302,6304} | {Presentations,OEB.global,"All which shall be presented is work-in-progress."}
{6301,6302,6305} | {Presentations,OEB.global,"Reform Pedagogy"}
{6301,6302,6305,6306} | {Presentations,OEB.global,"Reform Pedagogy","Waldorf Pedagogy"}
{6301,6302,6305,6307} | {Presentations,OEB.global,"Reform Pedagogy"," Montessori Pedagogy"}
{6301,6302,6305,6308} | {Presentations,OEB.global,"Reform Pedagogy","Freinet Pedagogy"}
{6301,6302,6309} | {Presentations,OEB.global," Commonalities among Waldorf / Montessori / Freinet"}
{6301,6302,6310}
into jsons having form
var treeData = [
{
"name": "Top Level",
"parent": "null",
"children": [
{
"name": "Level 2: A",
"parent": "Top Level",
"children": [
{
"name": "Son of A",
"parent": "Level 2: A"
},
{
"name": "Daughter of A",
"parent": "Level 2: A"
}
]
},
{
"name": "Level 2: B",
"parent": "Top Level"
}
]
}
];