I have a data structure like this:
list = [
%{
name: "cherry",
list: [
%{
name: "apple",
list: [
%{
name: "pear",
list: []
},
%{
name: "pineapple",
list: [
%{
name: "mango",
list: []
}
]
}
]
},
%{
name: "kiwi",
list: [
%{
name: "orange",
list: [
%{
name: "raspberry",
list: []
},
%{
name: "banana",
list: []
},
]
}
]
}
]
},
%{
name: "strawberry",
list: []
}
]
I need to convert it in a list of lists like below for that example:
[
["cherry", "apple", "pear"],
["cherry", "apple", "pineapple", "mango"],
["cherry", "kiwi", "orange", "raspberry"],
["cherry", "kiwi", "orange", "banana"],
["strawberry"]
]
You can see that each element in the list is kind of a “branch” of those maps that form like a tree.
I have tried today but I can’t figure it out
Even a small pseudo-code, or an idea, can help, thank you.