code: def _find_nearest_conn_objects(network, node, branches):
      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']
          station1_shp = transform(proj2equidistant(network), stations[0].geom)
          station2_shp = transform(proj2equidistant(network), stations[1].geom)
          line_shp = LineString([station1_shp, station2_shp])
          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)}}
          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']
          if isinstance(conn_objects['s1']['obj'], MVStation):
              del conn_objects['s1']
          elif isinstance(conn_objects['s2']['obj'], MVStation):
              del conn_objects['s2']
          conn_objects_min = min(conn_objects.values(), key=lambda v: v['dist'])
          conn_objects_min_stack.append(conn_objects_min)
      conn_objects_min_stack = [_ for _ in sorted(conn_objects_min_stack, key=lambda x: x['dist'])]
      return conn_objects_min_stack