def replace_kwargs(kwargs, param, types, *alias_tuple):
    """
    Replaces kwargs' names from alias_tuple to param.

    Iterate over `alias_tuple` and pop items from `kwargs`.
    If such name is in the `kwargs` and its type is instance of
    types sets `kwargs[param]` to `kwargs[alias]` value.

    :param dict kwargs: dict of functions parameters.
    :param str param: required name of function parameter.
    :param type types: required type of function parameter.
    :param tuple alias_tuple: a to_tuple of alias to replace
    :rtype: dict
    :return: changed kwargs
    """
    undefined = object()
    alias = undefined
    value = undefined
    for alias in alias_tuple:
        value = kwargs.get(alias, undefined)
        if undefined != value:
            break
    if value != undefined and isinstance(value, types):
        kwargs[param] = value
        kwargs.pop(alias, None)
    return kwargs