I've a hierarchical json object, I want to traverse it and attach a parent node to each element. This is what I've done
function attach_back_reference(hierarchy, parent){
hierarchy.parent = parent;
for(var i in hierarchy){
if(jQuery.isPlainObject(hierarchy[i]))
attach_back_reference(hierarchy[i], hierarchy);
}
}
But this is giving error. Maximum call stack size exceeded