docs: def _find_nearest_conn_objects(network, node, branches):
      """Searches all branches for the nearest possible connection object per branch
  
      It picks out 1 object out of 3 possible objects: 2 branch-adjacent stations
      and 1 potentially created branch tee on the line (using perpendicular projection).
      The resulting stack (list) is sorted ascending by distance from node.
  
      Parameters
      ----------
      network : :class:`~.grid.network.Network`
          The eDisGo container object
      node : :class:`~.grid.components.Component`
          Node to connect (e.g. :class:`~.grid.components.Generator`)
      branches :
          List of branches (NetworkX branch objects)
  
      Returns
      -------
      :obj:`list` of :obj:`dict`
          List of connection objects (each object is represented by dict with eDisGo object,
          shapely object and distance to node.
  
      Notes
      -----
      Adapted from `Ding0 <https://github.com/openego/ding0/blob/\
          21a52048f84ec341fe54e0204ac62228a9e8a32a/\
          ding0/grid/mv_grid/mv_connect.py#L38>`_.
      """
  
      # threshold which is used to determine if 2 objects are on the same position (see below for details on usage)
      conn_diff_tolerance = network.config['grid_connection'][
          'conn_diff_tolerance']
  
      conn_objects_min_stack = []
  
      node_shp = transform(proj2equidistant(network), node.geom)
  
      for branch in branches:
          stations = branch['adj_nodes']
  
          # create shapely objects for 2 stations and line between them, transform to equidistant CRS
          station1_shp = transform(proj2equidistant(network), stations[0].geom)
          station2_shp = transform(proj2equidistant(network), stations[1].geom)
          line_shp = LineString([station1_shp, station2_shp])
  
          # create dict with DING0 objects (line & 2 adjacent stations), shapely objects and distances
          conn_objects = {'s1': {'obj': stations[0],
                                 'shp': station1_shp,
                                 'dist': node_shp.distance(station1_shp) * 0.999},
                          's2': {'obj': stations[1],
                                 'shp': station2_shp,
                                 'dist': node_shp.distance(station2_shp) * 0.999},
                          'b': {'obj': branch,
                                'shp': line_shp,
                                'dist': node_shp.distance(line_shp)}}
  
          # Remove branch from the dict of possible conn. objects if it is too close to a node.
          # Without this solution, the target object is not unique for different runs (and so
          # were the topology)
          if (
                  abs(conn_objects['s1']['dist'] - conn_objects['b']['dist']) < conn_diff_tolerance
               or abs(conn_objects['s2']['dist'] - conn_objects['b']['dist']) < conn_diff_tolerance
             ):
              del conn_objects['b']
  
          # remove MV station as possible connection point
          if isinstance(conn_objects['s1']['obj'], MVStation):
              del conn_objects['s1']
          elif isinstance(conn_objects['s2']['obj'], MVStation):
              del conn_objects['s2']
  
          # find nearest connection point on given triple dict (2 branch-adjacent stations + cable dist. on line)
          conn_objects_min = min(conn_objects.values(), key=lambda v: v['dist'])
  
          conn_objects_min_stack.append(conn_objects_min)
  
      # sort all objects by distance from node
      conn_objects_min_stack = [_ for _ in sorted(conn_objects_min_stack, key=lambda x: x['dist'])]
  
      return conn_objects_min_stack