Collection<GitLocalBranch> (@Nullable GitRepository repository, @NotNull Map<GitRepository, Set<GitLocalBranch>> branchCollection) { if (repository != null) { return Objects.requireNonNullElse(branchCollection.get(repository), Collections.emptySet()); } return StreamEx.of(branchCollection.values()).flatMap(Set::stream).collect(Collectors.toSet()); }