private void buildResult(String curr, String begin, LinkedList<String> path, List<List<String>> result,
            HashMap<String, Integer> distance, HashMap<String, List<String>> backtrack) {
        path.add(0, curr);
        if (curr.equals(begin)) {
            result.add(new LinkedList<String>(path));
        } else {
            if (backtrack.containsKey(curr)) {
                for (String prev : backtrack.get(curr)) {
                    if (distance.containsKey(prev) && distance.get(curr) == distance.get(prev) + 1) {
                        buildResult(prev, begin, path, result, distance, backtrack);
                    }
                }
            }
        }
        path.remove(0);
    }