@NotNull
  @Override
  public Collection<PsiNamedElement> getNamedElements(String name, boolean includeNestedGlobals) {
    if (myNamedElements == null) {
      collectDeclarations();
    }
    if (myNamedElements.containsKey(name)) {
      final Collection<PsiNamedElement> elements = myNamedElements.get(name);
      elements.forEach(PyPsiUtils::assertValid);
      return elements;
    }
    if (includeNestedGlobals && isGlobal(name)) {
      for (Scope scope : myNestedScopes) {
        final Collection<PsiNamedElement> globals = scope.getNamedElements(name, true);
        if (!globals.isEmpty()) {
          globals.forEach(PyPsiUtils::assertValid);
          return globals;
        }
      }
    }
    return Collections.emptyList();
  }
@NotNull
  @Override
  public Collection<PsiNamedElement> getNamedElements(String name, boolean includeNestedGlobals)