void (VirtualFile root, MultiMap<VirtualFile, Pair<VirtualFile, String>> visitLog, Map<VirtualFile, String> backLog, int level, StringBuilder out) { List<Pair<VirtualFile, String>> visited = new ArrayList<>(visitLog.get(root)); visited.sort(Comparator.comparing(o -> o.first.getName())); for (Pair<VirtualFile, String> pair : visited) { String log = pair.second; out.append(StringUtil.repeat(" ", level)).append(log); VirtualFile child = pair.first; toLog(child, visitLog, backLog, level+1, out); String back = backLog.get(child); if (back != null) { out.append(StringUtil.repeat(" ", level)).append(back); } } }