def getSceneSelectionGroup(scene):
    """
    Get or create a selection group for scene.
    """
    selectionField = scene.getSelectionField()
    selectionGroup = selectionField.castGroup()
    if not selectionGroup.isValid():
        fm = scene.getRegion().getFieldmodule()
        selectionFieldName = 'cmiss_selection'
        selectionField = fm.findFieldByName(selectionFieldName)
        selectionGroup = selectionField.castGroup()
        if not selectionGroup.isValid():
            fm.beginChange()
            selectionField = fm.createFieldGroup()
            selectionField.setName(selectionFieldName)
            selectionGroup = selectionField.castGroup()
            fm.endChange()
        scene.setSelectionField(selectionField)
    return selectionGroup