+ else if ((copyTree->tree[i].getBranchLength() != -1) && (pcountSize == 1)) { UniqueBL += abs(copyTree->tree[i].getBranchLength()); }
+
+ //if you are a leaf from a users group add to total
+ if (i < numLeaves) {
+ if ((copyTree->tree[i].getBranchLength() != -1) && pcountSize != 0) {
+ totalBL += abs(copyTree->tree[i].getBranchLength());
+ }
+ tempTotals[i] = 0.0; //we don't care about you, or we have already added you
+ }else{ //if you are not a leaf
+ //do both your chidren have have descendants from the users groups?
+ int lc = copyTree->tree[i].getLChild();
+ int rc = copyTree->tree[i].getRChild();
+
+ //if yes, add your childrens tempTotals
+ if ((nodePcountSize[lc] != 0) && (nodePcountSize[rc] != 0)) {
+ totalBL += tempTotals[lc] + tempTotals[rc];
+
+ if (copyTree->tree[i].getBranchLength() != -1) {
+ tempTotals[i] = abs(copyTree->tree[i].getBranchLength());
+ }else {
+ tempTotals[i] = 0.0;
+ }
+ }else if ((nodePcountSize[lc] == 0) && (nodePcountSize[rc] == 0)) { tempTotals[i] = 0.0; //we don't care about you
+ }else { //if no, your tempTotal is your childrens temp totals + your branch length
+ tempTotals[i] = tempTotals[lc] + tempTotals[rc] + abs(copyTree->tree[i].getBranchLength());
+ }