public static TreeNodeWithParent findNext(TreeNodeWithParent node){
        if(node == null) return null;

        if(node.parent == null || node.right != null){
            return leftMostChild(node.right);
        }else{
            TreeNodeWithParent currParent = node.parent;
            while(currParent != null && currParent.left != node){
                node = currParent;
                currParent = currParent.parent;
            }
            return currParent;
        }
    }