private ArrayList<ArrayList<String>> getPath(HashMap<String, HashSet<String>> reverseLinks) {
        ArrayList<ArrayList<String>> result = new ArrayList<ArrayList<String>>();

        if(startWord.endsWith(endWord)){
            ArrayList<String> tmp = new ArrayList<String>();
            tmp.add(endWord);
            result.add(tmp);
            return result;
        }
        
        if(!reverseLinks.containsKey(endWord))
            return result;       

        
        LinkedList<Object> stack = new LinkedList<Object>();
        LinkedList<String> path = new LinkedList<String>();
        path.add(endWord);
        stack.push(path);
        stack.push(endWord);

        while (!stack.isEmpty()) {
            String word = (String) stack.pop();
            LinkedList<String> currentPath = (LinkedList<String>) stack.pop();
            if (!reverseLinks.containsKey(word)) {
                result.add(new ArrayList<String>(currentPath));
            } else {
                for (String from : reverseLinks.get(word)) {
                    LinkedList<String> newPath = new LinkedList<String>(currentPath);
                    newPath.push(from);
                    stack.push(newPath);
                    stack.push(from);
                }
            }
        }

        return result;
    }