I know I will need to do some type of recursion, but I'm not very experienced with the syntax of js and frameworks. I need to turn the following code into something that will search not just the Children of allNodes, but allNodes.Children[0].Children[0], allNodes.Children[1].Children[0], etc. and return the foundNode.
function findNodeById(id) {
var foundNode;
if (id === 0) {
foundNode = allNodes[0];
} else {
$.each(allNodes[0].Children, function(index, subNode) {
if (subNode.Id === id) {
foundNode = subNode;
return false;
}
});
};
return foundNode;
}
Here's what the data looks like if that helps: https://gist.github.com/matt-thorp333/09415cb90f8568f145b8b8526fc9ceb0