'Find a snapshot group that has remaining capacity for snapshots.
In order to minimize repository usage, we prioritize the snapshot
group with remaining snapshot capacity that has most recently had a
snapshot defined on it.
:param vol: An E-Series volume object
:return: A valid snapshot group that has available snapshot capacity,
or None
:raise NetAppDriverException: if the list of snapshot groups cannot be
retrieved'

def _get_available_snapshot_group(self, vol):

    groups_for_v = self._get_snapshot_groups_for_volume(vol)
    groups = [g for g in groups_for_v if (self.SNAPSHOT_VOL_COPY_SUFFIX not in g['label'])]
    groups = [g for g in groups if (not g['consistencyGroup'])]
    groups = [group for group in groups if (group.get('snapshotCount') < self.MAX_SNAPSHOT_COUNT)]
    if (len(groups) > 1):
        group_by_id = {g['id']: g for g in groups}
        snap_imgs = list()
        for group in groups:
            try:
                snap_imgs.append(self._get_latest_image_in_snapshot_group(group['id']))
            except exception.NotFound:
                pass
        snap_imgs = sorted(snap_imgs, key=(lambda x: x['pitSequenceNumber']))
        if snap_imgs:
            img = snap_imgs[(-1)]
            return group_by_id[img['pitGroupRef']]
        else:
            return (groups[0] if groups else None)
    elif groups:
        return groups[0]
    else:
        return None
