### Question:
RootMatcherSelector implements NodeSelector<E> { @Override public <N extends OpenNode<E, ? extends N>> Iterator<? extends N> select(Tree<E, ? extends N> tree) { final N root = tree.getRoot(); if (predicate.test(root)) { return new SingletonIterator<>(root); } else { return Collections.emptyIterator(); } } RootMatcherSelector(Predicate<OpenNode<? extends E, ?>> predicate); @Override Iterator<? extends N> select(Tree<E, ? extends N> tree);  }### Answer:
@Test public void select() { final NodeSelector<String> selector = new RootMatcherSelector<>(new EqualityMatcher<>("a")); final Iterator<? extends MutableSettableStructuredNode<String>> iterator = selector.select(tree); assertTrue(iterator.hasNext()); assertEquals("a", iterator.next().getElement()); assertFalse(iterator.hasNext()); }
@Test public void selectNothing() { final NodeSelector<String> selector = new RootMatcherSelector<>(new EqualityMatcher<>("b")); final Iterator<? extends MutableSettableStructuredNode<String>> iterator = selector.select(tree); assertFalse(iterator.hasNext()); }