<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _parse(self, text, mode):
 """ Returns a date, datetime or time depending on what information is available """

        if text is None or not text.strip():
            return None

        # first try to parse as an ISO8601 date, if it doesn't work we'll try other options
        if len(text) >= 16:
            try:
                parsed = iso8601.parse_date(text, default_timezone=None)
                if not parsed.tzinfo:
                    parsed = self._timezone.localize(parsed)

                return parsed
            except iso8601.ParseError:
                pass

        # split the text into numerical and text tokens
        tokens = regex.findall(r'([0-9]+|[^\W\d]+)', text, flags=regex.MULTILINE | regex.UNICODE | regex.V0)

        # get the possibilities for each token
        token_possibilities = []
        for token in tokens:
            possibilities = self._get_token_possibilities(token, mode)
            if len(possibilities) > 0:
                token_possibilities.append(possibilities)

        # see what valid sequences we can make
        sequences = self._get_possible_sequences(mode, len(token_possibilities), self._date_style)

        for sequence in sequences:
            match = OrderedDict()

            for c in range(len(sequence)):
                component = sequence[c]
                value = token_possibilities[c].get(component, None)
                match[component] = value

                if value is None:
                    break
            else:
                # try to make a valid result from this and return if successful
                obj = self._make_result(match, self._now, self._timezone)
                if obj is not None:
                    return obj

        return None