code: def _get_next_fname(fid, fname, tree):
      """Get the next filename in split files."""
      nodes_list = dir_tree_find(tree, FIFF.FIFFB_REF)
      next_fname = None
      for nodes in nodes_list:
          next_fname = None
          for ent in nodes["directory"]:
              if ent.kind == FIFF.FIFF_REF_ROLE:
                  tag = read_tag(fid, ent.pos)
                  role = int(tag.data.item())
                  if role != FIFF.FIFFV_ROLE_NEXT_FILE:
                      next_fname = None
                      break
              if ent.kind == FIFF.FIFF_REF_FILE_NAME:
                  tag = read_tag(fid, ent.pos)
                  next_fname = op.join(op.dirname(fname), tag.data)
              if ent.kind == FIFF.FIFF_REF_FILE_NUM:
                  # Some files don't have the name, just the number. So
                  # we construct the name from the current name.
                  if next_fname is not None:
                      continue
                  next_num = read_tag(fid, ent.pos).data.item()
                  path, base = op.split(fname)
                  idx = base.find(".")
                  idx2 = base.rfind("-")
                  num_str = base[idx2 + 1 : idx]
                  if not num_str.isdigit():
                      idx2 = -1
  
                  if idx2 < 0 and next_num == 1:
                      # this is the first file, which may not be numbered
                      next_fname = op.join(
                          path,
                          "%s-%d.%s"
                          % (base[:idx], next_num, base[idx + 1 :]),
                      )
                      continue
  
                  next_fname = op.join(
                      path,
                      "%s-%d.%s"
                      % (base[:idx2], next_num, base[idx + 1 :]),
                  )
          if next_fname is not None:
              break
      return next_fname
  
imports: import os.path
  from gzip import GzipFile
  from io import SEEK_SET, BytesIO
  import numpy
  from scipy.sparse import issparse
  from ..utils import _file_like, logger, verbose, warn
  from .constants import FIFF
  from .tag import Tag, _call_dict_names, _matrix_info, _read_tag_header, read_tag
  from .tree import dir_tree_find, make_dir_tree
label_desc: Use image node_id 2 for calling a global function with example usage: _get_next_fname(fid, fname, tree) and returns: next_fname