This is the Rcpp version of the heights_per_k.dendrogram from the dendextend R package. It is intended to override that function in order to get a speed gain of ranging from 10 times faster (for a tree with 3 leaves), to 130 times (!) faster (for a tree with 150 leaves).
Cuts the a tree at height h and returns a list with the FUN function implemented on all the sub trees created by cut at height h. This is used for creating a cutree.dendrogram function, by using the labels function as FUN.