@NotNull
 @Override
 public GlobalSearchScope uniteWith(@NotNull GlobalSearchScope scope) {
   if (scope == this || !scope.isSearchInLibraries() || !scope.isSearchOutsideRootModel())
     return this;
   return super.uniteWith(scope);
 }
  @NotNull
  public GlobalSearchScope uniteWith(@NotNull final GlobalSearchScope scope) {
    if (scope.isSearchOutsideRootModel()) {
      return super.uniteWith(scope);
    }

    return this;
  }
  @NotNull
  public GlobalSearchScope intersectWith(@NotNull final GlobalSearchScope scope) {
    if (scope.isSearchOutsideRootModel()) {
      return super.intersectWith(scope);
    }

    return scope;
  }
 @Override
 public boolean isSearchOutsideRootModel() {
   return myScope1.isSearchOutsideRootModel() && myScope2.isSearchOutsideRootModel();
 }