@@ -0,0 +1,828 @@
+package test;%0A%0Apublic class Test %7B%0A  public static class TreeNode %7B%0A    public int data;%0A    public TreeNode parent;%0A    public TreeNode left;%0A    public TreeNode right;%0A%0A    public TreeNode(int data) %7B%0A      this.data = data;%0A    %7D%0A%0A    @Override%0A    public String toString() %7B%0A      return %22TreeNode(%22 + data + %22, left=%22 + left + %22, right=%22 + right + %22)%22;%0A    %7D%0A  %7D%0A%0A  public static TreeNode successor(TreeNode node) %7B%0A    if (node == null) return null;%0A    if (node.right != null) %7B%0A      TreeNode tmp = node.right;%0A      while (tmp.left != null) %7B%0A        tmp = tmp.left;%0A      %7D%0A      return tmp;%0A    %7D else %7B%0A      TreeNode parent = node.parent;%0A      TreeNode tmp = node;%0A      while (parent != null && parent.right == tmp) %7B%0A        tmp = parent;%0A        parent = parent.parent;%0A      %7D%0A      return parent;%0A    %7D%0A  %7D%0A%7D%0A

add solution