@Override
	public int rewrite(final TreeNode<V> tree, final int limit) {
		requireNonNull(tree);

		int rewritten = 0;
		Optional<TreeMatchResult<V>> result;
		do {
			result = left().matcher(tree).results().findFirst();

			result.ifPresent(res -> rewrite(res, tree));
			rewritten += result.isPresent() ? 1 : 0;
		} while (result.isPresent() && rewritten < limit);

		return rewritten;
	}
Maps {@code this} rewrite rule from type {@code V} to type {@code B}.

@param mapper the type mapper
@param <B> the target type
@return a new rewrite rule for the mapped type
@throws NullPointerException if the {@code mapper} is {@code null}
jenetics.ext/src/main/java/io/jenetics/ext/rewriting/TreeRewriteRule.java