public static KdTree createTreeDuplicates() {

    KdTree tree = new KdTree(2);

    tree.root = new KdTree.Node(new double[] {1, 2}, null);
    tree.root.split = 1;
    tree.root.left = new KdTree.Node(new double[] {1, 2}, null);
    tree.root.left.split = 0;
    tree.root.left.left = new KdTree.Node(new double[] {1, 2}, null);
    tree.root.left.left.split = -1;
    tree.root.left.right = null;
    tree.root.right = new KdTree.Node(new double[] {1, 2}, null);
    tree.root.right.split = -1;

    return tree;
  }
  /** See if max distance is being respected */
  @Test
  public void findClosest_maxDistance() {
    KdTree tree = new KdTree(2);
    tree.root = new KdTree.Node(new double[] {1, 2}, null);

    KdTreeSearchN alg = createAlg();
    alg.setTree(tree);
    alg.setMaxDistance(2);

    found.reset();
    alg.findNeighbor(new double[] {11, 8}, 1, found);
    assertEquals(0, found.size);
    found.reset();
    alg.findNeighbor(new double[] {1, 1.5}, 1, found);
    assertEquals(1, found.size);
    assertTrue(found.data[0].node == tree.root);
  }