1var stack = [], node, ii;
2stack.push(root);
3
4while (stack.length > 0) {
5 node = stack.pop();
6 if (node.title == 'randomNode_1') {
7 // Found it!
8 return node;
9 } else if (node.children && node.children.length) {
10 for (ii = 0; ii < node.children.length; ii += 1) {
11 stack.push(node.children[ii]);
12 }
13 }
14}
15
16// Didn't find it. Return null.
17return null;