def groupByNodes(requestContext, seriesList, callback, *nodes):
    """
    Takes a serieslist and maps a callback to subgroups within as defined by
    multiple nodes.

    Example::

        &target=groupByNodes(ganglia.server*.*.cpu.load*,"sumSeries",1,4)

    Would return multiple series which are each the result of applying the
    "sumSeries" function to groups joined on the nodes' list (0 indexed)
    resulting in a list of targets like::

        sumSeries(ganglia.server1.*.cpu.load5),
        sumSeries(ganglia.server1.*.cpu.load10),
        sumSeries(ganglia.server1.*.cpu.load15),
        sumSeries(ganglia.server2.*.cpu.load5),
        sumSeries(ganglia.server2.*.cpu.load10),
        sumSeries(ganglia.server2.*.cpu.load15), ...

    """
    from .app import app
    metaSeries = {}
    keys = []
    if isinstance(nodes, int):
        nodes = [nodes]
    for series in seriesList:
        key = '.'.join(series.name.split(".")[n] for n in nodes)
        if key not in metaSeries:
            metaSeries[key] = [series]
            keys.append(key)
        else:
            metaSeries[key].append(series)
    for key in metaSeries:
        metaSeries[key] = app.functions[callback](requestContext,
                                                  metaSeries[key])[0]
        metaSeries[key].name = key
    return [metaSeries[key] for key in keys]

    Takes a serieslist and maps a callback to subgroups within as defined by
    multiple nodes.

    Example::

        &target=groupByNodes(ganglia.server*.*.cpu.load*,"sumSeries",1,4)

    Would return multiple series which are each the result of applying the
    "sumSeries" function to groups joined on the nodes' list (0 indexed)
    resulting in a list of targets like::

        sumSeries(ganglia.server1.*.cpu.load5),
        sumSeries(ganglia.server1.*.cpu.load10),
        sumSeries(ganglia.server1.*.cpu.load15),
        sumSeries(ganglia.server2.*.cpu.load5),
        sumSeries(ganglia.server2.*.cpu.load10),
        sumSeries(ganglia.server2.*.cpu.load15), ...

    
graphite_api/functions.py