code: def _get_config_by_discovery(self, node):
          
          path = self._get_node_dir(node)
  
          if path in self._cache:
              return self._cache[path]
  
          config_file = self._get_config_file_in_folder(path)
  
          if config_file is None:
              parent_dir, tail = os.path.split(path)
              if tail:
                  # No configuration file, simply take the parent's.
                  config = self._get_config(parent_dir)
              else:
                  # There's no configuration file and no parent directory.
                  # Use the default configuration or the one given in the CLI.
                  config = self._create_check_config(self._options)
          else:
              # There's a config file! Read it and merge if necessary.
              options, inherit = self._read_configuration_file(config_file)
  
              parent_dir, tail = os.path.split(path)
              if tail and inherit:
                  # There is a parent dir and we should try to merge.
                  parent_config = self._get_config(parent_dir)
                  config = self._merge_configuration(parent_config, options)
              else:
                  # No need to merge or parent dir does not exist.
                  config = self._create_check_config(options)
  
          return config
docs: Get a configuration for checking `node` by config discovery.
          
          Config discovery happens when no explicit config file is specified. The
          file system is searched for config files starting from the directory
          containing the file being checked, and up until the root directory of
          the project.
          
          See `_get_config` for further details.