def _recur_flatten(key, x, out, sep='.'):
    """Helper function to flatten_dict
    
    Recursively flatten all nested values within a dict
    
    Args:
        key (str): parent key
        x (object): object to flatten or add to out dict
        out (dict): 1D output dict
        sep (str): flattened key separator string
    
    Returns:
        dict: flattened 1D dict
    """
    if x is None or isinstance(x, (str, int, float, bool)):
        out[key] = x
        return out
    if isinstance(x, list):
        for i, v in enumerate(x):
            new_key = '{}{}{}'.format(key, sep, i)
            out = _recur_flatten(new_key, v, out, sep)
    if isinstance(x, dict):
        for k, v in x.items():
            new_key = '{}{}{}'.format(key, sep, k)
            out = _recur_flatten(new_key, v, out, sep)
    return out