Recursively pull from a dictionary, using dot notation, with default value
    instead of raised error (similar to dict.get()).

    >>> dig_get({"a":{"b":{"c":1}}}, "a.b.d")
    >>> dig_get({"a":{"b":{"c":1}}}, "a.b.d", 2)
    2
    >>> dig_get({"a":{"b":[{"c":1},{"d":4}]}}, "a.b[1].d", 2)
    4

def dig_get(obj, key, *default):
    """
    Recursively pull from a dictionary, using dot notation, with default value
    instead of raised error (similar to dict.get()).

    >>> dig_get({"a":{"b":{"c":1}}}, "a.b.d")
    >>> dig_get({"a":{"b":{"c":1}}}, "a.b.d", 2)
    2
    >>> dig_get({"a":{"b":[{"c":1},{"d":4}]}}, "a.b[1].d", 2)
    4
    """
    array = key.split(".")
    if default:
        default = default[0]
    else:
        default = None
    return _dig_get(obj, default, *array)