Using the DefaultTreeModel
, defaultmutbletreenode
's getRoot()
returns it's highest ancestor, but how would you go one generation down to return it's second highest ancestor?
root
- ancestor 1
- some parent
- some child
- ancestor 2
- some parent
- another parent
- some child
so how to find ancestor 1
, given some child
in this branch, the depth of each branch differs for each ancestor
node under root
.
I nee to traverse up to ancestor 1
from some child
, and also for a deeper branch, given some child
, it will find ancestor 2
.