public static TreeNode insertNode(TreeNode root, TreeNode node) {
        // write your code here
        if (root==null)
            return node;
        TreeNode p=null, c=root;
        while (c!=null) {
            if (c.val==node.val) {
                break;
            } else if (c.val<node.val) {
                p=c;
                c=c.right;
            } else {
                p=c;
                c=c.left;
            }
        }
        if (p.val<node.val) {
            p.right=node;
        } else if (p.val>node.val) {
            p.left=node;
        }
        return root;
    }