'Return a list of all KDTree nodes up to a certain tree height

I'm trying to return a list of all KDTree nodes up to a certain tree height. Tree dimension = 1. The tree split is by using the median.

I made a function but I was not able to retrieve all of them. I would like to get all the nodes as in the figure KDTree example.

def recursiveSplit(plane,height):
nodes = []
other = []
mid= plane/2
while height >= 0:
    plane = plane /2
    nodes.append(plane)
    height -= 1
other = [x+mid for x in nodes]
return nodes+other

results I'm getting

recursiveSplit(100,2)
[50.0, 25.0, 12.5, 100.0, 75.0, 62.5]


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source