title: Traverse PreOrder in BinarySearchTree (Java)
body: <p>i need some help. I already runned my full code via JUnit but I still get errors. I think its because of my traverse code. </p>
  
  <p>The purpose of the traverse code is to create a LinkedList in a in PreOrder.</p>
  
  <p>for example: JUnit always says that something like that is wrong</p>
  
  <pre><code>assertArrayEquals( new Integer[]{2, 14, 26, 86, 122, 134, 182},
      Arrays.copyOf(tree.traversePreOrder(), tree.getSize(), Integer[].class));
  </code></pre>
  
  <hr>
  
  <pre><code>@Override
  public Object[] traversePreOrder() {
      BinaryTreeNode&lt;T&gt; x = root;
      LinkedList&lt;Object&gt; y = new LinkedList&lt;Object&gt;();
  
      if (x == null) {
          return null;
      } else {
          y.add(x.value);
          y.add(travPreOrd(x.getLeft()));
          y.add(travPreOrd(x.getRight()));
      }
      return y.toArray();
  }
  
  public LinkedList&lt;Object&gt; travPreOrd(BinaryTreeNode&lt;T&gt; x) {
      BinaryTreeNode&lt;T&gt; tmp = x;
      LinkedList&lt;Object&gt; space = new LinkedList&lt;Object&gt;();
  
      if (x == null) {
          return null;
      } else {
          space.add(tmp.getValue());
          space.add(travPreOrd(x.getLeft()));
          space.add(travPreOrd(x.getRight()));
      }
      return space;
  }
  </code></pre>