<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def __set_text_field(text, text_type):
 # type: (str, str) -> Union[None, PlainText, RichText] """Helper method to create text field according to text type. :type text: str :param text_type: Type of the primary text field. Allowed values are `PlainText` and `RichText`. :type text_type: str :return: Object of type :py:class:`ask_sdk_model.interfaces.display.PlainText` or :py:class:`ask_sdk_model.interfaces.display.RichText` depending on text_type :rtype: object :raises: ValueError """

    if text:
        if text_type not in [PLAIN_TEXT_TYPE, RICH_TEXT_TYPE]:
            raise ValueError("Invalid type provided: {}".format(text_type))

        if text_type == PLAIN_TEXT_TYPE:
            return PlainText(text=text)
        else:
            return RichText(text=text)
    else:
        return None