<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def register_entity_to_group(self, entity, group):
        '''
        Add entity to a group.
        If group does not exist, entity will be added as first member
        entity is of type Entity
        group is a string that is the name of the group
        '''
        if entity in self._entities:
            if group in self._groups:
                self._groups[group].append(entity)
            else:
                self._groups[group] = [entity]
        else:
            raise UnmanagedEntityError(entity)