def METHOD_NAME(doc):
    """
    Parse FWJR document and yield the following structure:
    {"id": "requestName",
        "tasks": {
            "taskName1": {
                "sites": {
                    "siteName1":  {
                        "wrappedTotalJobTime": 1612,
                        "cmsRunCPUPerformance": {"totalJobCPU": 20, "totalJobTime": 42, "totalEventCPU": 4},
                        "inputEvents": 0,
                        "dataset": {}
                    }
                    "siteName2":  {
                        "wrappedTotalJobTime": 1612,
                        "cmsRunCPUPerformance": {"totalJobCPU": 20, "totalJobTime": 42, "totalEventCPU": 4},
                        "inputEvents": 0,
                        "dataset": {
                             "/a/b/c": {"size": 50, "events": 10, "totalLumis": 100},
                             "/a1/b1/c1": {"size": 50, "events": 10, "totalLumis": 100}
                        },
                    }
                },
            }
            "taskName2" : {}
        }
    }
    """
    # flag for the data collection, in some case fwjr doesn't contains the data needed
    # In that case it shouldn't crash but move on.
    dataCollectedFlag = False
    if 'fwjr' in doc:
        fwjr = doc['fwjr']
        if not isinstance(fwjr, dict):
            fwjr = fwjr.__to_json__(None)
    else:
        raise Exception('Document does not contain FWJR part')
    if 'task' not in fwjr:
        return dataCollectedFlag
    task_name = fwjr['task']
    try:
        req_name = task_name.split('/')[1]
    except:
        raise Exception('Cannot get request name from task_name "%s"' % task_name)
    # if one of the step has error except logArchive step don't collect the data
    for stepName in fwjr['steps']:
        if not stepName.startswith('logArch') and fwjr['steps'][stepName]['status'] != 0:
            return dataCollectedFlag
    sdict = {}  # all sites summary
    steps = fwjr['steps']
    wrappedTotalJobTime = 0
    pdict = dict(totalJobCPU=0, totalJobTime=0, totalEventCPU=0)
    ddict = {}
    for key, val in viewitems(steps):
        if val['stop'] is not None and val['start'] is not None:
            wrappedTotalJobTime += val['stop'] - val['start']
        site_name = val['site']
        site_summary = dict(wrappedTotalJobTime=wrappedTotalJobTime,
                            inputEvents=0, dataset=ddict,
                            cmsRunCPUPerformance=pdict)
        if key.startswith('cmsRun'):
            perf = val['performance']
            perf.setdefault('cpu', {})
            pdict['totalJobCPU'] += float(perf['cpu'].get('TotalJobCPU', 0))
            pdict['totalJobTime'] += float(perf['cpu'].get('TotalJobTime', 0))
            if 'TotalEventCPU' in perf['cpu']:
                pdict['totalEventCPU'] += float(perf['cpu']['TotalEventCPU'])
            else:
                pdict['totalEventCPU'] += float(perf['cpu'].get('TotalLoopCPU', 0))
            odict = val['output']
            for kkk, vvv in viewitems(odict):
                for row in vvv:
                    if row.get('merged', False):
                        prim = row['dataset']['primaryDataset']
                        proc = row['dataset']['processedDataset']
                        tier = row['dataset']['dataTier']
                        dataset = '/%s/%s/%s' % (prim, proc, tier)
                        totalLumis = sum([len(r) for r in viewvalues(row['runs'])])
                        dataset_summary = \
                            dict(size=row['size'], events=row['events'], totalLumis=totalLumis)
                        ddict[dataset] = dataset_summary
            if ddict:  # if we got dataset summary
                site_summary.update({'dataset': ddict})
            idict = val.get('input', {})
            if idict:
                source = idict.get('source', {})
                if isinstance(source, list):
                    for item in source:
                        site_summary['inputEvents'] += item.get('events', 0)
                else:
                    site_summary['inputEvents'] += source.get('events', 0)
        sdict[site_name] = site_summary
        dataCollectedFlag = True
    if dataCollectedFlag:
        # prepare final data structure
        sum_doc = dict(_id=req_name, tasks={task_name: dict(sites=sdict)})
        return sum_doc
    else:
        return dataCollectedFlag