Apply filter on ResourceIterable<Relationship> in Neo4j 5.20 (embedding in java)

I am migrating from Neo4j 2.3.8 (embedded) to 5.20 for one of my java applications.
Can you please guide me how to convert Sequence to ResourceIterable.
I am trying to fetch all relationships from the end node and apply two additional filters on top it using Sequence (com.googlecode.totallylazy) and return the Iterable.
However, with Neo4j 5.20, "expand" method of PathExpander returns ResourceIterable.
Either I need to add filters for ResourceIterable without using Sequence or I need to convert Sequence to ResourceIterable.
Can you please guide if there are any solutions available for either of the above options?

Existing code in Neo4j 2.3.8:

<
private static PathExpander overlappingRuns(final RunsCriteria criteria) {
return new PathExpander() {
@Override
public Iterable expand(Path path, BranchState state) {
return sequence(path.endNode().getRelationships())
.filter(relationships(StopsAt.class))
.filter(overlapping(criteria));
}

        @Override
        public PathExpander<Integer> reverse() {
            return this;
        }
    };
}

/>

Upgrading to Neo4j 5.2x: I have tried this way but its giving error "Type mismatch: cannot convert from Sequence to ResourceIterableJava(16777235)"

<
private static PathExpander overlappingRuns(final RunsCriteria criteria) {
return new PathExpander() {
@Override
public ResourceIterable expand(Path path, BranchState state) {

            return sequence(path.endNode().getRelationships())
                    .filter(relationships(StopsAt.class))
                    .filter(overlapping(criteria));

                    
        }

        @Override
        public PathExpander<Integer> reverse() {
            return this;
        }
    };
}

/>

I didn't see any utility in the docs to support converting an Iterable to a ResourceIterable. The difference is ResourceIterable also implements Resource, which just has a close() without throwing an exception.

You may try creating your own Sequence wrapper class that implements ResourceIterable. Something like this, but I have not tested this.

package com.example.resource_iterable;

import com.googlecode.totallylazy.Sequence;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.ResourceIterable;
import org.neo4j.graphdb.ResourceIterator;

import java.util.Spliterator;
import java.util.function.Consumer;
import java.util.stream.Stream;

public class MySequence implements ResourceIterable<Relationship> {

    private final Sequence<Relationship> sequence;

    public MySequence(Sequence<Relationship> sequence) {
        this.sequence = sequence;
    }
    
    @Override
    public ResourceIterator<Relationship> iterator() {
        return new ResourceIterator<>() {
            @Override
            public void close() {
            }

            @Override
            public boolean hasNext() {
                return sequence.iterator().hasNext();
            }

            @Override
            public Relationship next() {
                return sequence.iterator().next();
            }
        };
    }

    @Override
    public Stream<Relationship> stream() {
        return ResourceIterable.super.stream();
    }

    @Override
    public void forEach(Consumer<? super Relationship> action) {
        ResourceIterable.super.forEach(action);
    }

    @Override
    public Spliterator<Relationship> spliterator() {
        return ResourceIterable.super.spliterator();
    }

    @Override
    public void close() {
    }
}