def traverse_dict(data, key, default, delimiter=DEFAULT_TARGET_DELIM):
    '''
    Traverse a dict using a colon-delimited (or otherwise delimited, using the
    'delimiter' param) target string. The target 'foo:bar:baz' will return
    data['foo']['bar']['baz'] if this value exists, and will otherwise return
    the dict in the default argument.
    '''
    try:
        for each in key.split(delimiter):
            data = data[each]
    except (__HOLE__, IndexError, TypeError):
        # Encountered a non-indexable value in the middle of traversing
        return default
    return data
dataset/ETHPy150Open saltstack/salt/salt/utils/__init__.py/traverse_dict