public EdgeResult convertForViaWays(LongArrayList fromWays, LongArrayList viaWays, LongArrayList toWays) throws OSMRestrictionException {
        if (fromWays.isEmpty() || toWays.isEmpty() || viaWays.isEmpty())
            throw new IllegalArgumentException("There must be at least one from-, via- and to-way");
        if (fromWays.size() > 1 && toWays.size() > 1)
            throw new IllegalArgumentException("There can only be multiple from- or to-ways, but not both");
        List<IntArrayList> solutions = new ArrayList<>();
        for (LongCursor fromWay : fromWays)
            for (LongCursor toWay : toWays)
                findEdgeChain(fromWay.value, viaWays, toWay.value, solutions);
        if (solutions.size() < fromWays.size() * toWays.size())
            throw new OSMRestrictionException("has disconnected member ways");
        else if (solutions.size() > fromWays.size() * toWays.size())
            throw new OSMRestrictionException("has member ways that do not form a unique path");
        return buildResult(solutions, new EdgeResult(fromWays.size(), viaWays.size(), toWays.size()));
    }
@Test
    void convertForViaWays() throws OSMRestrictionException {
        BaseGraph graph = new BaseGraph.Builder(1).create();
        for (int i = 0; i < 10; i++)
            graph.edge(i, i + 1);
        WayToEdgeConverter.EdgeResult edgeResult = new WayToEdgeConverter(graph, way -> IntArrayList.from(Math.toIntExact(way)).iterator())
                .convertForViaWays(ways(0), ways(2, 6, 4, 1, 7, 3, 5, 8), ways(9));
        assertEquals(IntArrayList.from(1, 2, 3, 4, 5, 6, 7, 8), edgeResult.getViaEdges());
        assertEquals(IntArrayList.from(1, 2, 3, 4, 5, 6, 7, 8, 9), edgeResult.getNodes());
    }