public static <T> TreePath pathToCustomNode(@NotNull T node, @NotNull Function<? super T, ? extends T> getParent, @NotNull Function<? super T, Object> converter) {
    ArrayDeque<T> deque = new ArrayDeque<>();
    while (node != null) {
      deque.addFirst(node);
      node = getParent.apply(node);
    }
    return convertCollectionToTreePath(deque, converter);
  }
public static <T> TreePath pathToCustomNode(@NotNull T node, @NotNull Function<? super T, ? extends T> getParent, @NotNull Function<? super T, Object> converter)