class DefaultDependencyCollector implements DependencyCollector {

    @Nonnull
    @Override
    public DependencyCollectorResult collect(@Nonnull DependencyCollectorRequest request)
            throws DependencyCollectorException, IllegalArgumentException {<FILL_FUNCTION_BODY>}
}

        nonNull(request, "request");
        InternalSession session = InternalSession.from(request.getSession());

        Artifact rootArtifact;
        DependencyCoordinate root;
        Collection<DependencyCoordinate> dependencies;
        Collection<DependencyCoordinate> managedDependencies;
        List<RemoteRepository> remoteRepositories;
        if (request.getProject().isPresent()) {
            Project project = request.getProject().get();
            rootArtifact = project.getPomArtifact();
            root = null;
            dependencies = project.getDependencies();
            managedDependencies = project.getManagedDependencies();
            remoteRepositories = session.getService(ProjectManager.class).getRemoteProjectRepositories(project);
        } else {
            rootArtifact = request.getRootArtifact().orElse(null);
            root = request.getRoot().orElse(null);
            dependencies = request.getDependencies();
            managedDependencies = request.getManagedDependencies();
            remoteRepositories = session.getRemoteRepositories();
        }
        CollectRequest collectRequest = new CollectRequest()
                .setRootArtifact(rootArtifact != null ? session.toArtifact(rootArtifact) : null)
                .setRoot(root != null ? session.toDependency(root, false) : null)
                .setDependencies(session.toDependencies(dependencies, false))
                .setManagedDependencies(session.toDependencies(managedDependencies, true))
                .setRepositories(session.toRepositories(remoteRepositories));

        RepositorySystemSession systemSession = session.getSession();
        if (request.getVerbose()) {
            systemSession = new DefaultRepositorySystemSession(systemSession)
                    .setConfigProperty(ConflictResolver.CONFIG_PROP_VERBOSE, true)
                    .setConfigProperty(DependencyManagerUtils.CONFIG_PROP_VERBOSE, true);
        }

        try {
            final CollectResult result =
                    session.getRepositorySystem().collectDependencies(systemSession, collectRequest);
            return new DependencyCollectorResult() {
                @Override
                public List<Exception> getExceptions() {
                    return result.getExceptions();
                }

                @Override
                public Node getRoot() {
                    return session.getNode(result.getRoot(), request.getVerbose());
                }
            };
        } catch (DependencyCollectionException e) {
            throw new DependencyCollectorException("Unable to collect dependencies", e);
        }
    
<no_super_class>