Use a tree-based binning algorithm rather than the Fortran matrix-based method