So I am trying to figure out how to create a method that will search for a specific char, as well as keep track of the route used to reach it in the tree.
The method call looks like

System.out.println(mt.toMorseCode('S'));

The problem is that I am not sure how to do it when the parameter is the character. I copied the code from inOrderWalk thinking I could build of that to do the method toMorseCode, but then I realized that the parameters for that method are completely different. I am unsure where to begin.

public class MorseTree {
    TreeNode<Character> root = null;
 
    public MorseTree() {
        Scanner fin;
        try {
            fin = new Scanner(new File("data.txt"));
            while(fin.hasNext()){
                char letter = fin.next().charAt(0);
                String morse = fin.nextLine().trim();
                //System.out.println(morse + " = " + letter);    //prints out txt file
                add(morse, letter);
            }
        } catch (Exception e) {  //FileNotFound
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
 
    public void add(String morseStr, char letter) {
        root = insertInSubtree(morseStr, letter, root);
    }
 
    private TreeNode<Character> insertInSubtree(String morseStr, char letter, TreeNode<Character> subTree) {
        //base case 1 : subtree is null
        if(subTree == null){
            subTree = new TreeNode<Character>('~', null, null);     //~ means not defined
        }
        if(morseStr.length() == 0){
            subTree.data = letter;
        }else if(morseStr.charAt(0) == '.'){     //go right
            subTree.right = insertInSubtree(morseStr.substring(1), letter, subTree.right);
        }else{   //morseString.charAt(0) == '-')   // go left
            subTree.left = insertInSubtree(morseStr.substring(1), letter, subTree.left);
        }
        //base case 2 : morseStr is of length 0
        //recursive case 1: the first char in morseStr is a '.', so recursively traverse tree
        //recursive case 2: the first char in the morseStr is a '-', so recurse accordingly
 
        return subTree;  
    }
 
    public Character translate(String morseStr) {
        return findInSubtree(morseStr, root);
    }
 
    private Character findInSubtree(String morseStr, TreeNode<Character> subTree) {     //simular to insertInSubtree
        if(subTree == null){
            return '~';    //~ means not defined
        }else if(morseStr.length() == 0){
            return subTree.data;
        }else if(morseStr.charAt(0) == '.'){     //go right
           return findInSubtree(morseStr.substring(1), subTree.right);
        }else{   //morseString.charAt(0) == '-')   // go left
           return findInSubtree(morseStr.substring(1), subTree.left);
        }
    }
 
    public String translateString(String tokens) {
        String retVal = "";
        //build a scanner here using tokens as input
        Scanner text = new Scanner(tokens);
        while(text.hasNext()){
            String morseStr = text.next();
            retVal += translate(morseStr);
        }
 
        return retVal;
    }
 
    public String toMorseCode(Character c) {
        //walk the tree looking for the TreeNode with the char c in it
        String retVal = "";
        if(subTree != null){
            retVal += inorderWalk(subTree.left);
            retVal += subTree.data.toString()+",";
            retVal += inorderWalk(subTree.right);
        }
        return retVal;
            //preorder walk?
            //inorder walk? *********
            //postorder walk?
 
        //when you've found the char c, report the path from the root to the node
        //and build the morse code by adding a "." when you go right, "-" when you go left
    }
 
    public String toString() {
        return inorderWalk(root);
    }
 
    private String inorderWalk(TreeNode<Character> subTree) {  
        String retVal = "";
        if(subTree != null){
            retVal += inorderWalk(subTree.left);
            retVal += subTree.data.toString()+",";
            retVal += inorderWalk(subTree.right);
        }
        return retVal;
    }
 
    public static void main(String[] args) {
        MorseTree mt = new MorseTree();  //builds our tree using data from a file
 
        System.out.println(mt.translate("...."));  //h
        System.out.println(mt.translate("."));     //e
        System.out.println(mt.translate(".-.."));  //l
        System.out.println(mt.translate(".-.."));  //l
        System.out.println(mt.translate("---"));   //0
 
 
        System.out.println(mt.translateString("... --- ..."));  //SOS
        System.out.println(mt.translateString(".... --- .-.. .-")); //Hola
        System.out.println(mt.toMorseCode('S'));  //find where we are in the tree, remember path to root
    }
 
    private class TreeNode<TBA extends Comparable>{
        TBA data;
        TreeNode<TBA> left;
        TreeNode<TBA> right;
 
        public TreeNode(TBA d, TreeNode<TBA> l, TreeNode<TBA> r){
            data = d;
            left = l;
            right = r;
        }
    }
 
}