docs: def extend_substation_voltage(crit_stations, grid_level='LV'):
      """
      Extend substation if voltage issues at the substation occur
  
      Follows a two-step procedure:
      
      i) Existing transformers are extended by replacement with large nominal
         apparent power
        
      ii) New additional transformers added to substation (see 'Notes')
  
      Parameters
      ----------
      crit_stations : :any:`list`
          List of stations with overloading or voltage issues.
      grid_level : str
          Specifiy grid level: 'MV' or 'LV'
  
      Notes
      -----
      At maximum 2 new of largest (currently 630 kVA) transformer are additionally
      built to resolve voltage issues at MV-LV substation bus bar.
      """
      grid = crit_stations[0]['node'].grid
      trafo_params = grid.network._static_data['{grid_level}_trafos'.format(
          grid_level=grid_level)]
      trafo_s_max_max = max(trafo_params['S_nom'])
      trafo_min_size = trafo_params.loc[trafo_params['S_nom'].idxmin(), :]
  
      v_diff_max_fc = cfg_ding0.get('assumptions', 'lv_max_v_level_fc_diff_normal')
      v_diff_max_lc = cfg_ding0.get('assumptions', 'lv_max_v_level_lc_diff_normal')
  
      tree = nx.dfs_tree(grid._graph, grid._station)
  
      for station in crit_stations:
          v_delta = max(station['v_diff'])
  
          # get list of nodes of main branch in right order
          extendable_trafos = [_ for _ in station['node']._transformers
                               if _.s_max_a < trafo_s_max_max]
  
          v_delta_initially_lc = v_delta[0]
          v_delta_initially_fc = v_delta[1]
  
          new_transformers_cnt = 0
  
          # extend existing trafo power while voltage issues exist and larger trafos
          # are available
          while (v_delta[0] > v_diff_max_lc) or (v_delta[1] > v_diff_max_fc):
              if extendable_trafos:
                  # extend power of first trafo to next higher size available
                  extend_trafo_power(extendable_trafos, trafo_params)
              elif new_transformers_cnt < 2:
                  # build a new transformer
                  lv_transformer = TransformerDing0(
                      grid=grid,
                      id_db=id,
                      v_level=0.4,
                      s_max_longterm=trafo_min_size['S_nom'],
                      r=trafo_min_size['R'],
                      x=trafo_min_size['X'])
  
                  # add each transformer to its station
                  grid._station.add_transformer(lv_transformer)
  
                  new_transformers_cnt += 1
  
              # update break criteria
              v_delta = get_voltage_at_bus_bar(grid, tree)
              extendable_trafos = [_ for _ in station['node']._transformers
                                   if _.s_max_a < trafo_s_max_max]
  
              if (v_delta[0] == v_delta_initially_lc) or (
                  v_delta[1] == v_delta_initially_fc):
                  logger.warning("Extension of {station} has no effect on "
                                 "voltage delta at bus bar. Transformation power "
                                 "extension is halted.".format(
                      station=station['node']))
                  break