public TreeNode<Integer> findNext(TreeNode<Integer> n) {
		if (n == null)
			return null;
		if (n.right != null) {
			TreeNode<Integer> p = n.right;
			while (p.left != null) {
				p = p.left;
			}
			return p;
		} else {
			TreeNode<Integer> p = n.parent;
			while (p.parent != null) {
				if (p == p.parent.left)
					return p;
				p = p.parent;
			}
			return null;
		}
	}