def recursively_get_filenames(path, filenames, recursion_depth, current_recursion_level=0):
    """
    Get all filenames (python/yaml) that attributes should be read from.

    Parameters
    ----------
    path : str or path-like object
        the current directory
    filenames : str
        The base filenames.
    recursion_depth : int
        The maximum recursion depth (0 = only current directory, 1 = current and parents).
        -1 means recurse until root.
    current_recursion_level : int, Optional, default = 0
        Current recursion level of the function.

    Returns
    -------
    filenames: list
        A list of filenames, where the ones further up front in the list are further up in the directory tree.
        The files do not need to exist.
    """
    this_dir_files = [path / pyfile for pyfile in filenames]
    if path.parent == path: # root directory
        return this_dir_files
    elif recursion_depth == -1:
        parentfiles = recursively_get_filenames(
            path.parent, filenames, recursion_depth, current_recursion_level + 1)
        return parentfiles + this_dir_files
    elif current_recursion_level >= recursion_depth:
        return this_dir_files
    else:
        parentfiles = recursively_get_filenames(
            path.parent, filenames, recursion_depth, current_recursion_level + 1)
        return parentfiles + this_dir_files