private double computeMaxPathWeight ( int node ) { if ( node == - 1 || levels [ node ] == 0 ) { return 0 ; } double leftMaxWeight = computeMaxPathWeight ( lefts [ node ] ) ; double rightMaxWeight = computeMaxPathWeight ( rights [ node ] ) ; return Math . max ( leftMaxWeight , rightMaxWeight ) + counts [ node ] ; }
Computes the max weight of any path starting at node and ending at a leaf in the hypothetical complete tree . The weight is the sum of counts in the ancestors of a given node