func (st *StatsTree) accumulate() {
	for k, v := range st.byID {
		if v.parentID != 0 {
			parent := st.byID[v.parentID]
			parent.children = append(parent.children, k)
		}
	}
	s := make([]int64, 0)
	for k, v := range st.byID {
		if len(v.children) == 0 {
			s = append(s, k)
		}
	}
	for len(s) > 0 {
		parents := make(map[int64]bool)
		for i := range s {
			node := st.byID[s[i]]
			if node.parentID != 0 {
				p := st.byID[node.parentID]  
				parents[p.id] = true         
				p.cuIDs.Merge(node.cuIDs)    
			}
		}
		s = make([]int64, len(parents))
		i := 0
		for k := range parents {
			s[i] = k
			i++
		}
	}
	root := new(StatsNode)
	root.uid = "root"
	root.cuIDs = make(IDSet)
	st.byID[-1] = root
	for _, v := range st.byID {
		if v.parentID == 0 {
			root.cuIDs.Merge(v.cuIDs)
		}
	}
}
accumulate merge Histograms bottom up so that
parent nodes's Histogram will be the overall sum of its children.
We do that in code because we don't really know how to do that with SQL.
package api
import (
	"database/sql"
	"fmt"
	"github.com/Bnei-Baruch/sqlboiler/queries"
	"github.com/lib/pq"
	"github.com/pkg/errors"
	"gopkg.in/volatiletech/null.v6"
	"github.com/Bnei-Baruch/archive-backend/mdb/models"
	"github.com/Bnei-Baruch/sqlboiler/queries/qm"
)
type ClassificationStats map[string]int
func (s ClassificationStats) dump() {
	fmt.Printf("%d entries\n", len(s))
	for k, v := range s {
		fmt.Printf("%s\t\t%+v\n", k, v)
	}
}
type IDSet map[int64]bool
func (h IDSet) Increment(k int64) {
	h[k] = true
}
func (h IDSet) Merge(other IDSet) {
	for k := range other {
		h.Increment(k)
	}
}
type StatsNode struct {
	id       int64
	parentID int64
	uid      string
	children []int64
	cuIDs    IDSet
}
type StatsTree struct {
	byID map[int64]*StatsNode
}
func NewStatsTree() *StatsTree {
	st := new(StatsTree)
	st.byID = make(map[int64]*StatsNode)
	return st
}