title: Aggregation in hierarchical tree
body: <p>Need to do aggregation in hierarchical tree structure using Java, Please suggest some good methods or API to do this.</p>
  
  <p>Tree Structure:</p>
  
  <p>A is a root node and it has two nodes B and C.
  B has two child nodes B1 and B2 and similarly C has two child nodes C1 and C2. Each leaf node has some value associated.</p>
  
  <p>I need to aggregate values starting from leaf to all the way root node. </p>
  
  <p>In above example, if the values of leaf nodes are B1=5, B2=5, C1=3 and C2=7. Then Aggregation would give value 10 to B node and 10 to C node. Root node A will have value 20.</p>
  
  <p>Please suggest solution.</p>
  
  <p>I have to load the tree structure from file. My file is like below.</p>
  
  <p>Node|Id|ParentId<br/>
  A|1|1<br/>
  B|2|1<br/>
  C|3|1<br/>
  B1|4|2<br/>
  B2|5|2<br/>
  C1|6|3<br/>
  C2|7|3<br/></p>