i want you to carefully integrate this function into my code or at least its method:  public static TreeNode genericToBinary(TreeNode root) {
        if (root == null || root.child.size() == 0) {
            return root;
        }

        root.left = genericToBinary(root.child.get(0));
        TreeNode curr = root.left;

        for (int i = 1; i < root.child.size(); i++) {
            curr.right = genericToBinary(root.child.get(i));
            curr = curr.right;
        }

        return root;
    },my code:import java.io.*;
import java.util.*;

public class Main {

    public static Map<String, List<String>> importGeneralizedTree(String input) {
        Map<String, List<String>> tree = new HashMap<>();
        try (BufferedReader br = new BufferedReader(new FileReader(input))) {
            String line;
            while ((line = br.readLine()) != null) {
                if (line.trim().isEmpty()) continue; // Skip empty lines
                String[] parts = line.replaceAll("\\s+", "").split("->");
                String parent = parts[0];
                List<String> children = new ArrayList<>();
                if (parts.length > 1) {
                    children = Arrays.asList(parts[1].split(","));
                }
                tree.put(parent, children);
            }
        } catch (FileNotFoundException e) {
            System.err.println("The file " + input + " was not found");
        } catch (IOException e) {
            System.err.println("An error occurred while reading the file " + input + ".");
        }
        return tree;
    }

    public static void exportBinaryTree(Map<String, String[]> binaryTree, String filename) {
        try (BufferedWriter bw = new BufferedWriter(new FileWriter(filename))) {
            for (Map.Entry<String, String[]> entry : binaryTree.entrySet()) {
                String node = entry.getKey();
                String[] children = entry.getValue();
                String leftChild = (children[0] != null) ? children[0] : "null";
                String rightChild = (children[1] != null) ? children[1] : "null";
                bw.write("Node " + node + ": Left -> " + leftChild + ", Right -> " + rightChild);
                bw.newLine();
            }
        } catch (IOException e) {
            System.err.println("An error occurred while writing to the file " + filename + ".");
        }
    }


    public static void main(String[] args) {
        String inputFilename = "input.txt";
        String outputFilename = "output.txt";

        if (args.length > 0) {
            inputFilename = args[0];
        }
        if (args.length > 1) {
            outputFilename = args[1];
        }

        // Import generalized tree from the input file
        Map<String, List<String>> gTree = importGeneralizedTree(inputFilename);

        if (gTree.isEmpty()) {
            System.err.println("The generalized tree is empty or could not be loaded. Exiting.");
            return;
        }

        System.out.println("Generalized Tree: " + gTree);
    }

    private static String binaryTreeToString(Map<String, String[]> binaryTree) {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        for (Map.Entry<String, String[]> entry : binaryTree.entrySet()) {
            String node = entry.getKey();
            String[] children = entry.getValue();
            String leftChild = (children[0] != null) ? children[0] : "null";
            String rightChild = (children[1] != null) ? children[1] : "null";
            sb.append(node).append("=[").append(leftChild).append(", ").append(rightChild).append("], ");
        }
        if (sb.length() > 1) {
            sb.setLength(sb.length() - 2); // Remove the last comma and space
        }
        sb.append("}");
        return sb.toString();
    }
}