public Node ceiling(int x){
            Node cur = root;
            while(true){
                if(cur.value==x) return cur;
                if(x<cur.value){
                    if(cur.left==null){
                        return cur;
                    }
                    cur = cur.left;
                } else{
                    if(cur.right==null){
                        while(cur.parent!=null && cur==cur.parent.right) cur=cur.parent;
                        return cur.parent;
                    }
                    cur = cur.right;
                }
            }
        }