k2tree implementation