You could use a defaultdict(list) here, exactly as I did in https://github.com/gem/oq-engine/pull/1073/files.