void (String expected, Function<? super TreeTest, ? extends Promise<TreePath>> function) { TreeTest.test(TreeUtilVisitTest::rootDeep, test -> function.apply(test) .onSuccess(path -> test.invokeSafely(() -> Assert.fail("found unexpected path: " + path))) .onError(error -> test.invokeSafely(() -> { Assert.assertTrue(error instanceof CancellationException); test.assertTree(expected, test::done); }))); }