from itertools import chain
    allindices = chain.from_iterable(s['indices'] for s in allsnaps if 'snapshot' in s and s['state'] == 'SUCCESS')
    return set(i for i in allindices if i.startswith(prefix))

though is checking for the 'snapshot' key necessary?