def METHOD_NAME(sizesByFilename):
    sizesByDirectory = {}
    for filename in sizesByFilename:
        for path in ancestorPaths(filename):
            sizesByDirectory[path] = sizesByDirectory[path]+sizesByFilename[filename] if path in sizesByDirectory else sizesByFilename[filename]
    return sizesByDirectory