Applies the callback to the contained value if the option
        is not :py:data:`NONE`.

        This is different than :py:meth:`Option.map` because the result
        of the callback isn't wrapped in a new :py:class:`Option`

        Args:
            callback: The callback to apply to the contained value.

        Returns:
            :py:data:`NONE` if the option is :py:data:`NONE`.

            otherwise calls `callback` with the contained value and
            returns the result.

        Examples:
            >>> def square(x): return Some(x * x)
            >>> def nope(x): return NONE
            >>> Some(2).flatmap(square).flatmap(square)
            Some(16)
            >>> Some(2).flatmap(square).flatmap(nope)
            NONE
            >>> Some(2).flatmap(nope).flatmap(square)
            NONE
            >>> NONE.flatmap(square).flatmap(square)
            NONE

def flatmap(self, callback: 'Callable[[T], Option[U]]') -> 'Option[U]':
        """
        Applies the callback to the contained value if the option
        is not :py:data:`NONE`.

        This is different than :py:meth:`Option.map` because the result
        of the callback isn't wrapped in a new :py:class:`Option`

        Args:
            callback: The callback to apply to the contained value.

        Returns:
            :py:data:`NONE` if the option is :py:data:`NONE`.

            otherwise calls `callback` with the contained value and
            returns the result.

        Examples:
            >>> def square(x): return Some(x * x)
            >>> def nope(x): return NONE
            >>> Some(2).flatmap(square).flatmap(square)
            Some(16)
            >>> Some(2).flatmap(square).flatmap(nope)
            NONE
            >>> Some(2).flatmap(nope).flatmap(square)
            NONE
            >>> NONE.flatmap(square).flatmap(square)
            NONE
        """
        return callback(self._val) if self._is_some else cast('Option[U]', NONE)