function findAllWords(node, arr) {
    // base case, if node is at a word, push to output
    if (node.end) {
        arr.unshift(node.getWord());
    }

    // iterate through each children, call recursive findAllWords
    for (var child in node.children) {
        findAllWords(node.children[child], arr);
    }
}
// recursive function to find all words in the given node.
recursive function to find all words in the given node.
recursive function to find all words in the given node .
function findAllWords(node, arr) {
    if (node.end) {
        arr.unshift(node.getWord());
    }
    for (var child in node.children) {
        findAllWords(node.children[child], arr);
    }
}
function findAllWords ( node , arr ) { if ( node . end ) { arr . unshift ( node . getWord ( ) ) ; } for ( var child in node . children ) { findAllWords ( node . children [ child ] , arr ) ; } }
recursive function to find all words in the given node.
recursive function to find all words in the given node .
// base case, if node is at a word, push to output // iterate through each children, call recursive findAllWords