Merge the leaves in the minimum way to have groups number of clusters.
Them number of children the first level of the tree should have.
Returns a list of indices for all the leaves of this cluster. The list is ordered in such a way that a dendrogram could be drawn without crossing branches.
Traverses the tree depth-first and calls the provided callback with each individual node
The callback to be called on each node encounter
Creates an array of clusters where the maximum height is smaller than the threshold.