import six


def key_by_value_dict(in_dict, value):
    """ Reverse dictionary lookup.

        Args:
            in_dict (dict): Input dict.
            value: Lookup value.

        Returns:
            Key in ``in_dict`` containing ``value`` if found.

        >>> key_by_value_dict({'key1': 42, 'key2': 'forty-two'}, 42)
        'key1'
        >>> key_by_value_dict({'key1': 42, 'key2': 'forty-two'}, 'forty-two')
        'key2'
        >>> key_by_value_dict({'key1': 42, 'key2': 'forty-two'}, '1') is None
        True

    """
    for k, v in six.iteritems(in_dict):
        if value == v:
            return k