title
var tree = [
{
name:"a",
children:[
{
name:"aa",
children:[
{
name:"aaa"
},
{
name:"aaa1"
},
{
name:"aaa2"
},
{
name:"aaa3"
}
]
},
{
name:"aa1",
children:[
{
name:"aaaa1"
},
{
name:"aaaa2"
}
]
}
]
},
{
name:"b",
children:[
{
name:"bb",
children:[
{
name:"bbb",
children:[
{
name:"bbbb1"
}
]
},
{
name:"bbb1"
},
{
name:"bbb2"
},
{
name:"bbb3"
}
]
}
]
}
]
requirements
returns an array of each level
[
["a"],
["b"],
["a","aa"],
["a","aa1"],
["a","aa","aaa"],
["a","aa","aaa1"],
["a","aa","aaa2"],
["a","aa","aaa3"],
["a","aa1","aaaa1"],
["a","aa1","aaaa2"],
["b","bb"],
["b","bb","bbb"],
["b","bb","bbb1"],
["b","bb","bbb2"],
["b","bb","bbb3"],
["b","bb","bbb","bbbb1"]
]