code: def create(point_list=None, dimensions=None, axis=0, sel_axis=None):
      
  
      if not point_list and not dimensions:
          raise ValueError('either point_list or dimensions must be provided')
  
      elif point_list:
          dimensions = check_dimensionality(point_list, dimensions)
  
      # by default cycle through the axis
      sel_axis = sel_axis or (lambda prev_axis: (prev_axis+1) % dimensions)
  
      if not point_list:
          return KDNode(sel_axis=sel_axis, axis=axis, dimensions=dimensions)
  
      # Sort point list and choose median as pivot element
      point_list = list(point_list)
      point_list.sort(key=lambda point: point[axis])
      median = len(point_list) // 2
  
      loc   = point_list[median]
      left  = create(point_list[:median], dimensions, sel_axis(axis))
      right = create(point_list[median + 1:], dimensions, sel_axis(axis))
      return KDNode(loc, left, right, axis=axis, sel_axis=sel_axis, dimensions=dimensions)
docs: Creates a kd-tree from a list of points
  
      All points in the list must be of the same dimensionality.
  
      If no point_list is given, an empty tree is created. The number of
      dimensions has to be given instead.
  
      If both a point_list and dimensions are given, the numbers must agree.
  
      Axis is the axis on which the root-node should split.
  
      sel_axis(axis) is used when creating subnodes of a node. It receives the
      axis of the parent node and returns the axis of the child node.