private int getDepth() {
		Stack<TreeNode<E>> nodeStack = new Stack<TreeNode<E>>();
		Stack<Integer> leftStack = new Stack<Integer>();
		Stack<Integer> rightStack = new Stack<Integer>();

		nodeStack.push(root);
		leftStack.push(-1);
		rightStack.push(-1);

		while (true) {
			TreeNode<E> t = nodeStack.peek();
			int left = leftStack.peek();
			int right = rightStack.peek();

			if (t == null) {
				nodeStack.pop();
				leftStack.pop();
				rightStack.pop();
				int value = 0;
				if (nodeStack.isEmpty())
					return value;
				else if (leftStack.peek() == -1) {
					leftStack.pop();
					leftStack.push(value);
				} else {
					rightStack.pop();
					rightStack.push(value);
				}
			} else if (left == -1) {
				nodeStack.push(t.left);
				leftStack.push(-1);
				rightStack.push(-1);
			} else if (right == -1) {
				nodeStack.push(t.right);
				leftStack.push(-1);
				rightStack.push(-1);
			} else {
				nodeStack.pop();
				leftStack.pop();
				rightStack.pop();
				int value = 1 + Math.max(left, right);
				if (nodeStack.isEmpty())
					return value;
				else if (leftStack.peek() == -1) {
					leftStack.pop();
					leftStack.push(value);
				} else {
					rightStack.pop();
					rightStack.push(value);
				}
			}
		}
	}