private @NotNull Node toNode(
    @Nullable Node parent,
    @NotNull CachedTreePresentation cachedPresentation,
    @NotNull TreePath nodePath
  ) {
    var object = nodePath.getLastPathComponent();
    var result = new Node(object, cachedPresentation.isLeaf(object) ? LeafState.ALWAYS : LeafState.NEVER);
    if (parent == null) {
      result.paths.add(new CachingTreePath(object));
    }
    else {
      for (TreePath path : parent.paths) {
        result.paths.add(path.pathByAddingChild(object));
      }
    }
    tree.map.put(object, result);
    var resultChildren = cachedPresentation.getChildren(nodePath.getLastPathComponent());
    if (resultChildren != null) {
      result.children = ContainerUtil.map(resultChildren, child -> toNode(result, cachedPresentation, nodePath.pathByAddingChild(child)));
    }
    return result;
  }
private @NotNull Node toNode(
    @Nullable Node parent,
    @NotNull CachedTreePresentation cachedPresentation,
    @NotNull TreePath nodePath
  )