private Node insert(Node root,String data,int pos){
        if(pos == data.length()){
            return root;
        }
        if(root == null){
            root = new Node();
            root.data = data.charAt(pos);
            root.eq = insert(root.eq,data,pos+1);
            if(pos == (data.length()-1)){
                root.isLeaf = true;
            }
        }else{
            if(root.data == data.charAt(pos)){
                root.eq = insert(root.eq,data,pos+1);
                if(pos == (data.length()-1)){
                    root.isLeaf = true;
                }
            }
            else if(root.data < data.charAt(pos)){
                root.right = insert(root.right,data,pos);
            }else{
                root.left = insert(root.left,data,pos);
            }
        }
        return root;
    }
http://www.geeksforgeeks.org/ternary-search-tree/
src/com/interview/suffixprefix/TernaryTree.java