def _determine_aggregated_nodes(la_centers):
    """Determine generation and load within load areas

    Parameters
    ----------
    la_centers: list of LVLoadAreaCentre
        Load Area Centers are Ding0 implementations for representating areas of
        high population density with high demand compared to DG potential.

    Notes
    -----
    Currently, MV grid loads are not considered in this aggregation function as
    Ding0 data does not come with loads in the MV grid level.

    Returns
    -------
    :obj:`list` of dict
        aggregated
        Dict of the structure

        .. code:

            {'generation': {
                'v_level': {
                    'subtype': {
                        'ids': <ids of aggregated generator>,
                        'capacity'}
                    }
                },
            'load': {
                'consumption':
                    'residential': <value>,
                    'retail': <value>,
                    ...
                }
            'aggregates': {
                'population': int,
                'geom': `shapely.Polygon`
                }
            }
    :obj:`list`
        aggr_stations
        List of LV stations its generation and load is aggregated
    """

    def aggregate_generators(gen, aggr):
        """Aggregate generation capacity per voltage level

        Parameters
        ----------
        gen: ding0.core.GeneratorDing0
            Ding0 Generator object
        aggr: dict
            Aggregated generation capacity. For structure see
            `_determine_aggregated_nodes()`.

        Returns
        -------

        """

        if gen.v_level not in aggr['generation']:
            aggr['generation'][gen.v_level] = {}
        if gen.type not in aggr['generation'][gen.v_level]:
            aggr['generation'][gen.v_level][gen.type] = {}
        if gen.subtype not in aggr['generation'][gen.v_level][gen.type]:
            aggr['generation'][gen.v_level][gen.type].update(
                     {gen.subtype: {'ids': [gen.id_db],
                                'capacity': gen.capacity}})
        else:
            aggr['generation'][gen.v_level][gen.type][gen.subtype][
                'ids'].append(gen.id_db)
            aggr['generation'][gen.v_level][gen.type][gen.subtype][
                'capacity'] += gen.capacity

        return aggr

    def aggregate_loads(la_center, aggr):
        """Aggregate consumption in load area per sector

        Parameters
        ----------
        la_center: LVLoadAreaCentreDing0
            Load area center object from Ding0

        Returns
        -------

        """
        for s in ['retail', 'industrial', 'agricultural', 'residential']:
            if s not in aggr['load']:
                aggr['load'][s] = 0

        aggr['load']['retail'] += sum(
            [_.sector_consumption_retail
             for _ in la_center.lv_load_area._lv_grid_districts])
        aggr['load']['industrial'] += sum(
            [_.sector_consumption_industrial
             for _ in la_center.lv_load_area._lv_grid_districts])
        aggr['load']['agricultural'] += sum(
            [_.sector_consumption_agricultural
             for _ in la_center.lv_load_area._lv_grid_districts])
        aggr['load']['residential'] += sum(
            [_.sector_consumption_residential
             for _ in la_center.lv_load_area._lv_grid_districts])

        return aggr

    aggregated = {}
    aggr_stations = []

    # ToDo: The variable generation_aggr is further used -> delete this code
    generation_aggr = {}
    for la in la_centers[0].grid.grid_district._lv_load_areas:
        for lvgd in la._lv_grid_districts:
            for gen in lvgd.lv_grid.generators():
                if la.is_aggregated:
                    generation_aggr.setdefault(gen.type, {})
                    generation_aggr[gen.type].setdefault(gen.subtype, {'ding0': 0})
                    generation_aggr[gen.type][gen.subtype].setdefault('ding0', 0)
                    generation_aggr[gen.type][gen.subtype]['ding0'] += gen.capacity

    dingo_import_data = pd.DataFrame(columns=('id',
                                              'capacity',
                                              'agg_geno')
                                     )

    for la_center in la_centers:
        aggr = {'generation': {}, 'load': {}, 'aggregates': []}

        # Determine aggregated generation in LV grid
        for lvgd in la_center.lv_load_area._lv_grid_districts:
            weather_cell_ids = {}
            for gen in lvgd.lv_grid.generators():
                aggr = aggregate_generators(gen, aggr)

                # Get the aggregated weather cell id of the area
                # b
                if isinstance(gen, GeneratorFluctuatingDing0):
                    if gen.weather_cell_id not in weather_cell_ids.keys():
                        weather_cell_ids[gen.weather_cell_id] = 1
                    else:
                        weather_cell_ids[gen.weather_cell_id] += 1

                dingo_import_data.loc[len(dingo_import_data)] = \
                    [int(gen.id_db),
                     gen.capacity,
                     None]

            # Get the weather cell id that occurs the most if there are any generators
            if not(list(lvgd.lv_grid.generators())):
                weather_cell_id = None
            else:
                if weather_cell_ids:
                    weather_cell_id = list(weather_cell_ids.keys())[
                        list(weather_cell_ids.values()).index(
                            max(weather_cell_ids.values()))]
                else:
                    weather_cell_id = None

            for v_level in aggr['generation']:
                for type in aggr['generation'][v_level]:
                    for subtype in aggr['generation'][v_level][type]:
                        # make sure to check if there are any generators before assigning
                        # a weather cell id
                        if not(list(lvgd.lv_grid.generators())):
                            pass
                        else:
                            aggr['generation'][v_level][type][subtype]['weather_cell_id'] = \
                                weather_cell_id

        # Determine aggregated load in MV grid
        # -> Implement once laods in Ding0 MV grids exist

        # Determine aggregated load in LV grid
        aggr = aggregate_loads(la_center, aggr)

        # Collect metadata of aggregated load areas
        aggr['aggregates'] = {
            'population': la_center.lv_load_area.zensus_sum,
            'geom': la_center.lv_load_area.geo_area}

        # Determine LV grids/ stations that are aggregated
        for _ in la_center.lv_load_area._lv_grid_districts:
            aggr_stations.append(_.lv_grid.station())

        # add elements to lists
        aggregated.update({la_center.id_db: aggr})

    return aggregated, aggr_stations, dingo_import_data