Q:

how to get all child node in treeview of YUI

I want all the childs of given node in YUI treeview. Condition is that if the child has sub-childs then I want sub-sub-child. that is all the childs of given node including subchilds.
I think recursion may be the solution for this problem.Can anyone help me out this.  
My current code is
if(curNode.hasChildren()) {
  for(var child = 0; child < curNode.children.length;child++) {
    alert(curNode.children[child].label);
   }
}

By this code, I only get the childrens of given node and not the sub-sub-child nodes.

A:

var root = $("#root")[0];
var nodeList = [];

function appendChildren(node, array) {
    if (node.hasChildNodes()) {
        for (var i = 0; i < node.children.length; i++) {
            if (node.children[i].hasChildNodes()) {
                appendChildren(node.children[i], array);
                array.push(node.children[i]);
            }
        }
    }
}

appendChildren(root, nodeList);

Tested here.
A recursive solution. This can be done more elegantly using functional style programming. This one relies on underscore.js for a cross browser .reduce implementation. You can rely on array.reduce if you target newer browsers.
function nodeToChildren(node) {
    if (node.hasChildren()) {
        _.reduce(node.children, function (memo, val) {
            return memo.concat(nodeToChildren(val));
        }, [].concat(node));
    } else {
        return node;
    }
}

var array = nodeToChildren(root);

Give me a few moments to test/debug this.
I forgot the jQuery option
var array = $(root).find("*").toArray()

