So I have a folder tree that looks a bit like
- grandad
- parent 1
- ana
- jack
- david
- parent 2
- fred
- lydia
- david
- parent 3
- alfred
- jo
- david
...so every single parent folder has a child called david
.
What I want to do is to be able to traverse the tree from the grandad to one particular david and do something inside it without having to write n number of
while iterator.hasnext() {
const child = iterator.next()
}
as it can get pretty cumbersome if david happens to be a few levels down.
Is there a way to do this elegantly and avoiding repetition?
Thanks!