public static TreeNode BTToDLL(TreeNode root){
        if(root == null) return null;

        TreeNode head = root;
        if(root.left != null){
            TreeNode node = BTToDLL(root.left);
            head = node;
            while(node.right != null){
                node = node.right;
            }
            node.right = root;
            root.left = node;

        }

        if(root.right != null){
            TreeNode node = BTToDLL(root.right);
            root.right = node;
            node.left = root;
        }
        return head;
    }