let rec find_k_nearest_1 t k s x =
    if length t = 0
    then []
    else
      let dist n = match n with Node (x1,_,_) -> distance x x1 in
      let children n = match n with Node (_,_,c) -> c in
      let s1 = int_of_float (s *. (float_of_int max_degree)) in
      let nearest_roots =
        flatten (map children (fst (select (order_by_asc dist) s1 t))) in
      let nearest_in_subtrees = find_k_nearest_1 nearest_roots k s x in
      (fst (select
              (order_by_asc dist)
              k
              (t @ nearest_in_subtrees)))