var arr = [
{
name:"",
id:1,
parent_id: 0,
child:[
{
name:"",
id:2,
parent_id: 1,
child:[
{
now: true,
name:"",
id:4,
parent_id: 2
},{
now: false,
name:"",
id:5,
parent_id: 2
}
]
},
{
name:"",
id:3,
parent_id: 1,
child:[
{
now: true,
name:"",
parent_id: 3,
id:6
},{
now: false,
name:"",
parent_id: 3,
id:7
}
]
}]
},
{
name:"",
id:8,
parent_id: 0,
child:[
{
name:"",
id:9,
parent_id: 8,
child:[
{
now: true,
name: "",
id:11,
parent_id: 9
},{
now: false,
name:"",
id:12,
parent_id: 9
}
]
},
{
name:"",
id:10,
parent_id: 8,
child:[
{
now: false,
name:"",
parent_id: 10,
id:13
},{
now: false,
name:"",
parent_id: 10,
id:14
}
]
}]
},
];
I want to get the last level of the array if now is true, then find his parent according to his parent_id,
then get it and its parent"s id, so keep getting its parent
and finally return an array result is
so how to find it?