void () { try { while (State.STARTED == state.get()) { ArrayDeque<N> siblings = stack.peek(); if (siblings == null) { update(State.STARTED, State.FINISHED); current = null; promise.setResult(null); return; // nothing to process } N node = siblings.poll(); if (node == null) { TreePath path = current; if (path == null) throw new IllegalStateException(); if (siblings != stack.poll()) throw new IllegalStateException(); current = path.getParentPath(); } else { TreePath path = TreePathUtil.createTreePath(current, converter.apply(node)); switch (visitor.visit(path)) { case CONTINUE -> { update(State.STARTED, State.REQUESTED); if (processChildren(path, node)) break; return; // stop processing and wait for setChildren } case INTERRUPT -> { update(State.STARTED, State.FINISHED); current = null; stack.clear(); promise.setResult(path); return; // path is found } case SKIP_SIBLINGS -> siblings.clear(); case SKIP_CHILDREN -> {} } } } } catch (Exception error) { setError(error); } }