private static @Nullable GlobalSearchScope tryCreateUnionFor2Scopes(GlobalSearchScope @NotNull [] scopes) {
      assert scopes.length == 2;
      GlobalSearchScope scope0 = scopes[0];
      GlobalSearchScope scope1 = scopes[1];
      if (scope0 == EMPTY_SCOPE) return scope1;
      if (scope1 == EMPTY_SCOPE) return scope0;
      if (scope0 instanceof UnionScope && scope1 instanceof UnionScope) return null;
      Project project = ObjectUtils.chooseNotNull(scope0.getProject(), scope1.getProject());

      if (scope0 instanceof UnionScope) {
        return unionWithUnionScope(scope0, scope1, project);
      }

      if (scope1 instanceof UnionScope) {
        return unionWithUnionScope(scope1, scope0, project);
      }

      return new UnionScope(project, scopes);
    }
private static @Nullable GlobalSearchScope tryCreateUnionFor2Scopes(GlobalSearchScope @NotNull [] scopes)