lib/collections/Tree.js
function (node, order, callback) {
            if (node) {
                order = order || Tree.PRE_ORDER;
                if (order === Tree.PRE_ORDER) {
                    callback(node.data);
                    this.traverse(node.left, order, callback);
                    this.traverse(node.right, order, callback);
                } else if (order === Tree.IN_ORDER) {
                    this.traverse(node.left, order, callback);
                    callback(node.data);
                    this.traverse(node.right, order, callback);
                } else if (order === Tree.POST_ORDER) {
                    this.traverse(node.left, order, callback);
                    this.traverse(node.right, order, callback);
                    callback(node.data);
                } else if (order === Tree.REVERSE_ORDER) {
                    this.traverseWithCondition(node.right, order, callback);
                    callback(node.data);
                    this.traverseWithCondition(node.left, order, callback);

                }
            }
        }
function (node, order, callback) {
            if (node) {
                order = order || Tree.PRE_ORDER;
                if (order === Tree.PRE_ORDER) {
                    callback(node.data);
                    this.traverse(node.left, order, callback);
                    this.traverse(node.right, order, callback);
                } else if (order === Tree.IN_ORDER) {
                    this.traverse(node.left, order, callback);
                    callback(node.data);
                    this.traverse(node.right, order, callback);
                } else if (order === Tree.POST_ORDER) {
                    this.traverse(node.left, order, callback);
                    this.traverse(node.right, order, callback);
                    callback(node.data);
                } else if (order === Tree.REVERSE_ORDER) {
                    this.traverseWithCondition(node.right, order, callback);
                    callback(node.data);
                    this.traverseWithCondition(node.left, order, callback);

                }
            }
        }
function ( node , order , callback ) { if ( node ) { order = order || Tree . PRE_ORDER ; if ( order === Tree . PRE_ORDER ) { callback ( node . data ) ; this . traverse ( node . left , order , callback ) ; this . traverse ( node . right , order , callback ) ; } else if ( order === Tree . IN_ORDER ) { this . traverse ( node . left , order , callback ) ; callback ( node . data ) ; this . traverse ( node . right , order , callback ) ; } else if ( order === Tree . POST_ORDER ) { this . traverse ( node . left , order , callback ) ; this . traverse ( node . right , order , callback ) ; callback ( node . data ) ; } else if ( order === Tree . REVERSE_ORDER ) { this . traverseWithCondition ( node . right , order , callback ) ; callback ( node . data ) ; this . traverseWithCondition ( node . left , order , callback ) ; } } }
Traverse a tree

<p><b>Not typically used directly</b></p>

@param {Object} node the node to start at
@param {Tree.PRE_ORDER|Tree.POST_ORDER|Tree.IN_ORDER|Tree.REVERSE_ORDER} [order=Tree.IN_ORDER] the traversal scheme
@param {Function} callback called for each item
Traverse a tree