For one leaf, the largest dimension is determined, and then pixels are sorted according to this dimension and half of it goes into one branch and the rest into the other.
GetDimensionValue returns a value along an axis, that can be used to sort values / determine min-max.
There is indeed a sort of averaging for the leaf.