Promise<TreeVisitor> (@NotNull Object element) { return Promises.asPromise(onValidThread(struct -> { return new TreeVisitor.ByTreePath<>( TreePathUtil.pathToCustomNode(element, struct::getParentElement), node -> node instanceof Node ? ((Node)node).getElement() : null ); })); }