class ProjectBuildList implements Iterable<ProjectSegment> {
    private final List<ProjectSegment> items;

    public ProjectBuildList(List<ProjectSegment> items) {
        this.items = Collections.unmodifiableList(items);
    }

    // TODO Optimize; or maybe just rewrite the whole way aggregating mojos are being run.
    /**
     * Returns aProjectBuildList that contains only items for the specified taskSegment
     * @param taskSegment the requested task segment
     * @return a project build list for the supplied task segment
     */
    public ProjectBuildList getByTaskSegment(TaskSegment taskSegment) {
        return new ProjectBuildList(
                items.stream().filter(pb -> taskSegment == pb.getTaskSegment()).collect(Collectors.toList()));
    }

    public Map<MavenProject, ProjectSegment> selectSegment(TaskSegment taskSegment) {
        return items.stream()
                .filter(pb -> taskSegment == pb.getTaskSegment())
                .collect(Collectors.toMap(ProjectSegment::getProject, Function.identity()));
    }

    /**
     * Finds the first ProjectSegment matching the supplied project
     * @param mavenProject the requested project
     * @return The projectSegment or null.
     */
    public ProjectSegment findByMavenProject(MavenProject mavenProject) {
        return items.stream()
                .filter(pb -> mavenProject.equals(pb.getProject()))
                .findFirst()
                .orElse(null);
    }

    @Override
    public Iterator<ProjectSegment> iterator() {
        return items.iterator();
    }

    public void closeAll() {
        for (ProjectSegment item : items) {
            MavenSession sessionForThisModule = item.getSession();
            sessionForThisModule.setCurrentProject(null);
        }
    }

    public int size() {
        return items.size();
    }

    public ProjectSegment get(int index) {
        return items.get(index);
    }

    public Set<String> getReactorProjectKeys() {<FILL_FUNCTION_BODY>}

    public boolean isEmpty() {
        return items.isEmpty();
    }

    /**
     * @return a set of all the projects managed by the build
     */
    public Set<MavenProject> getProjects() {
        return items.stream().map(ProjectSegment::getProject).collect(Collectors.toSet());
    }
}

        Set<String> projectKeys = new HashSet<>(items.size() * 2);
        for (ProjectSegment projectBuild : items) {
            MavenProject project = projectBuild.getProject();
            String key = ArtifactUtils.key(project.getGroupId(), project.getArtifactId(), project.getVersion());
            projectKeys.add(key);
        }
        return projectKeys;
    
<no_super_class>