public static void flatten(TreeNode root) {
        if(root == null){
        	return ;
        }
        
    	Queue<TreeNode> currentLevel = new LinkedList<TreeNode>();
    	TreeNode newNode = new TreeNode(root.val);
    	TreeNode head = newNode;
    	TreeNode empty = new TreeNode(0);
        currentLevel.add(root);
        while(!currentLevel.isEmpty()){
        	Queue<TreeNode> nextLevel = new LinkedList<TreeNode>();
        	while(!currentLevel.isEmpty()){
        		TreeNode node = currentLevel.poll();
        		if(newNode.right != null){
        			newNode = newNode.right;
        		}
        		newNode.left = null;
        		newNode.right  = node;
        		if(node.left != null) nextLevel.add(node.left);
        		if(node.right != null) nextLevel.add(node.right);
        	}
        	currentLevel = nextLevel;
        }
        root = head.right;
    }