class ProjectSelector {
    private static final Logger LOGGER = LoggerFactory.getLogger(ProjectSelector.class);

    public Set<MavenProject> getRequiredProjectsBySelectors(
            MavenExecutionRequest request, List<MavenProject> projects, Set<String> projectSelectors)
            throws MavenExecutionException {
        Set<MavenProject> selectedProjects = new LinkedHashSet<>();
        File baseDirectory = getBaseDirectoryFromRequest(request);
        for (String selector : projectSelectors) {
            Optional<MavenProject> optSelectedProject =
                    findOptionalProjectBySelector(projects, baseDirectory, selector);
            if (!optSelectedProject.isPresent()) {
                String message = "Could not find the selected project in the reactor: " + selector;
                throw new MavenExecutionException(message, request.getPom());
            }

            MavenProject selectedProject = optSelectedProject.get();

            selectedProjects.add(selectedProject);
            selectedProjects.addAll(getChildProjects(selectedProject, request));
        }

        return selectedProjects;
    }

    public Set<MavenProject> getOptionalProjectsBySelectors(
            MavenExecutionRequest request, List<MavenProject> projects, Set<String> projectSelectors) {<FILL_FUNCTION_BODY>}

    private List<MavenProject> getChildProjects(MavenProject parent, MavenExecutionRequest request) {
        final List<MavenProject> children = parent.getCollectedProjects();
        if (children != null && request.isRecursive()) {
            return children;
        } else {
            return new ArrayList<>();
        }
    }

    private Optional<MavenProject> findOptionalProjectBySelector(
            List<MavenProject> projects, File reactorDirectory, String selector) {
        return projects.stream()
                .filter(project -> isMatchingProject(project, selector, reactorDirectory))
                .findFirst();
    }

    File getBaseDirectoryFromRequest(MavenExecutionRequest request) {
        return request.getBaseDirectory() != null ? new File(request.getBaseDirectory()) : null;
    }

    boolean isMatchingProject(MavenProject project, String selector, File reactorDirectory) {
        // [groupId]:artifactId
        if (selector.contains(":")) {
            String id = ':' + project.getArtifactId();

            if (id.equals(selector)) {
                return true;
            }

            id = project.getGroupId() + id;

            return id.equals(selector);
        }

        // relative path, e.g. "sub", "../sub" or "."
        else if (reactorDirectory != null) {
            File selectedProject =
                    new File(new File(reactorDirectory, selector).toURI().normalize());

            if (selectedProject.isFile()) {
                return selectedProject.equals(project.getFile());
            } else if (selectedProject.isDirectory()) {
                return selectedProject.equals(project.getBasedir());
            }
        }

        return false;
    }
}

        Set<MavenProject> resolvedOptionalProjects = new LinkedHashSet<>();
        Set<String> unresolvedOptionalSelectors = new HashSet<>();
        File baseDirectory = getBaseDirectoryFromRequest(request);
        for (String selector : projectSelectors) {
            Optional<MavenProject> optSelectedProject =
                    findOptionalProjectBySelector(projects, baseDirectory, selector);
            if (optSelectedProject.isPresent()) {
                resolvedOptionalProjects.add(optSelectedProject.get());
                resolvedOptionalProjects.addAll(getChildProjects(optSelectedProject.get(), request));
            } else {
                unresolvedOptionalSelectors.add(selector);
            }
        }

        if (!unresolvedOptionalSelectors.isEmpty()) {
            LOGGER.info("The requested optional projects {} do not exist.", unresolvedOptionalSelectors);
        }

        return resolvedOptionalProjects;
    
<no_super_class>