This code gives me only first level in hierarchy of a tree. How can I check a node to the point the node is leaf and add all those children as value for parent in a TreeMap
for (TreeItem node : root.getChildren()) {
mytreemap.put(node.getValue().toString(), node.getChildren());
}
It gives
{a = [TreeItem [ value: 1, [ TreeItem [ value: 2], b= [TreeItem [ value:b1]}
I need to have { a = [1,2] b= [b1,b2,b2-1,b2-2]}
a
1
2
b
b1
-b2
b2-1
b2-2