class SimpleMergeRequestManager implements MergeRequestManager {

    @Override
    public List<List<Comment>> getComments(Resource requestId) {
        getMergeRequest(requestId).orElseThrow(
                () -> new IllegalArgumentException("MergeRequest " + requestId + " does not exist"));

        List<List<Comment>> commentChains = new ArrayList<>();
        try (RepositoryConnection conn = configProvider.getRepository().getConnection()) {
            TupleQuery query = conn.prepareTupleQuery(GET_COMMENT_CHAINS);
            query.setBinding("mergeRequest", requestId);
            query.evaluate().forEach(bindings -> {
                bindings.getValue("parent").ifPresent(parent -> {
                    List<String> chain = new ArrayList<String>(Arrays.asList(
                            Bindings.requiredLiteral(bindings, "chain").stringValue().split(" ")));
                    chain.add(0, parent.stringValue());
                    chain.remove("");
                    commentChains.add(chain.stream().map(vf::createIRI)
                            .map(iri -> getComment(iri).orElseThrow(() -> new IllegalStateException("Comment " + iri
                                    + " does not exist.")))
                            .collect(Collectors.toList()));
                });
            });
        }
        return commentChains;
    }

}