code: def check_voltage(grid, mode):
      crit_nodes = {}
      if mode == 'MV':
          mv_max_v_level_lc_diff_normal = float(cfg_ding0.get('mv_routing_tech_constraints',
                                                              'mv_max_v_level_lc_diff_normal'))
          mv_max_v_level_fc_diff_normal = float(cfg_ding0.get('mv_routing_tech_constraints',
                                                              'mv_max_v_level_fc_diff_normal'))
          voltage_station = grid._station.voltage_res
          for node in grid.graph_nodes_sorted():
              try:
                  if (abs(voltage_station[0] - node.voltage_res[0]) > mv_max_v_level_lc_diff_normal) or\
                     (abs(voltage_station[1] - node.voltage_res[1]) > mv_max_v_level_fc_diff_normal):
                      crit_nodes[node] = {'node': node,
                                          'v_diff': max([abs(v2-v1) for v1, v2 in zip(node.voltage_res, voltage_station)])}
              except:
                  pass
      elif mode == 'LV':
          raise NotImplementedError
      if crit_nodes:
          logger.info('==> {} nodes have voltage issues.'.format(len(crit_nodes)))
      return [_['node'] for _ in sorted(crit_nodes.values(), key=lambda _: _['v_diff'], reverse=True)]