def _init_data(data, key, init_data):
    """Initialize the data at specified key, if needed"""
    if isinstance(key, int):
        try:
            data[key]
        except IndexError:
            data.append(init_data)
    else:
        data[key] = data.get(key, init_data)
    return data
