'Iterate over the datasets of a given collection, recursing into collections, and
calling fn on each dataset.
Uses the same kwargs as `contents` above.'

def map_datasets(self, content, fn, *parents):

    returned = []
    collection = (content.collection if hasattr(content, 'collection') else content)
    this_parents = ((content,) + parents)
    for element in collection.elements:
        next_parents = ((element,) + this_parents)
        if element.is_collection:
            processed_list = self.map_datasets(element.child_collection, fn, *next_parents)
            returned.extend(processed_list)
        else:
            processed = fn(element.dataset_instance, *next_parents)
            returned.append(processed)
    return returned
