code: def _create_subscript_in(atom, root):
      """Find / create and insert object defined by `atom` from list `root`
  
      The `atom` has an index, defined in ``atom.obj_id``.  If `root` is long
      enough to contain this index, return the object at that index.  Otherwise,
      extend `root` with None elements to contain index ``atom.obj_id``, then
      create a new object via ``atom.obj_type()``, insert at the end of the list,
      and return this object.
  
      Can therefore modify `root` in place.
      """
      curr_n = len(root)
      index = atom.obj_id
      if curr_n > index:
          return root[index]
      obj = atom.obj_type()
      root += [None] * (index - curr_n) + [obj]
      return obj
  
file_path: nibabel/nibabel/nicom/ascconv.py
imports: import ast
  import re
  from collections import OrderedDict
label_desc: Use image node_id 3 for calling a global function with example usage: _create_subscript_in(atom, root) and returns: obj, root