private void dfsTraversal(SuffixNode root, List<Character> result){
        if(root == null){
            return;
        }
        if(root.index != -1){
            for(int i=root.start; i <= root.end.end; i++){
                result.add(input[i]);
            }
            result.stream().forEach(System.out::print);
            System.out.println(" " + root.index);
            for(int i=root.start; i <= root.end.end; i++){
                result.remove(result.size()-1);
            }
            return;
        }
        
        for(int i=root.start; i <= root.end.end; i++){
            result.add(input[i]);
        }
        
        for(SuffixNode node : root.child){
            dfsTraversal(node, result);
        }
        
        for(int i=root.start; i <= root.end.end; i++){
            result.remove(result.size()-1);
        }
       
    }
Do a DFS traversal of the tree.
src/com/interview/suffixprefix/SuffixTree.java