<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def _prepare_mock(context: 'torment.contexts.TestContext', symbol: str, return_value = None, side_effect = None) -> None:
    '''Sets return value or side effect of symbol's mock in context.

    .. seealso:: :py:func:`_find_mocker`

    **Parameters**

    :``context``:       the search context
    :``symbol``:        the symbol to be located
    :``return_value``:  pass through to mock ``return_value``
    :``side_effect``:   pass through to mock ``side_effect``

    '''

    methods = symbol.split('.')
    index = len(methods)

    mock = None

    while index > 0:
        name = 'mocked_' + '_'.join(methods[:index]).lower()
        logger.debug('name: %s', name)

        if hasattr(context, name):
            mock = getattr(context, name)
            break

        index -= 1

    logger.debug('mock: %s', mock)

    if mock is not None:
        mock = functools.reduce(getattr, methods[index:], mock)
        logger.debug('mock: %s', mock)

        if return_value is not None:
            mock.return_value = return_value

        if side_effect is not None:
            mock.side_effect = side_effect

        mock.reset_mock()