<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def find1(self, kw: YangIdentifier, arg: str = None, pref: YangIdentifier = None, required: bool = False) -> Optional["Statement"]: """Return first substatement with the given parameters. Args: kw: Statement keyword (local part for extensions). arg: Argument (all arguments will match if ``None``). pref: Keyword prefix (``None`` for built-in statements). required: Should an exception be raised on failure? Raises: StatementNotFound: If `required` is ``True`` and the statement is not found. """

        for sub in self.substatements:
            if (sub.keyword == kw and sub.prefix == pref and
                    (arg is None or sub.argument == arg)):
                return sub
        if required:
            raise StatementNotFound(str(self), kw)