<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_unit_by_name(self, unit_name: str) -> typing.Optional['BaseUnit']: """ Gets a unit from its name Args: unit_name: unit name Returns: """

        VALID_STR.validate(unit_name, 'get_unit_by_name')
        for unit in self.units:

            if unit.unit_name == unit_name:
                return unit
        return None