lib/middleware/nodes/getChildren.js
function loadChild(node, cb){
        db.nodes.getByParent(node._id.toString()).then(
            function(data){
                payload = payload.concat(data);
                async.each(data, loadChild, cb);
            }).done();
    }
function loadChild(node, cb){
        db.nodes.getByParent(node._id.toString()).then(
            function(data){
                payload = payload.concat(data);
                async.each(data, loadChild, cb);
            }).done();
    }
function loadChild ( node , cb ) { db . nodes . getByParent ( node . _id . toString ( ) ) . then ( function ( data ) { payload = payload . concat ( data ) ; async . each ( data , loadChild , cb ) ; } ) . done ( ) ; }
Recursive function to load children and save them into the payload
Recursive function to load children and save them into the payload