var flatten = function(a, shallow,r){ if(!r){ r = []} if (shallow) { return r.concat.apply(r,a); } for(var i=0; i