private static <Label, Out> Set<List<Out>> run(List<TreeNode<Label>> paths,
			F1<Label, Out> selector) {
		SequencesSemiRing<Out> c = new SequencesSemiRing<>();

		Set<List<Out>> allResults = c.zero();
		for (TreeNode<Label> path : paths) {
			Set<List<Out>> result = c.one();

			for (Label step : path.getPath()) {
				Set<List<Out>> p = Collections.singleton(Collections
						.singletonList(selector.$(step)));
				result = c.times(result, p);
			}

			allResults = c.plus(allResults, result);
		}

		return allResults;
	}