@SuppressWarnings("unchecked")
	public E[] toArray() {
		if (root == null) 
			return null;
		
		E[] array = (E[]) Array.newInstance(root.data.getClass(), size);
		Stack<Node> stack = new Stack<Node>();
		Node node = root;
		int index = 0;
		
		while (true) {
			if (node != null) {
				stack.push(node);
				node = node.left;
			} else {
				node = stack.pop();
				array[index++] = node.data;
				if (index == size)
					break;
				node = node.right;
			}
		}
		
		return array;
	}