from pathlib import Path
from collections import namedtuple

FilePathElements = namedtuple(
    "FilePathElements", ["anchor", "name", "stem", "suffix", "ancestors"]
)


def analyze_file_path(file_path: str) -> FilePathElements | None:
    """
    Analyze elements of a given file path.

    A path is considered valid only if it exists on disk. The returned
    ``ancestors`` are parent directories (as strings), ordered from the
    immediate parent directory up to the filesystem root.

    Parameters
    ----------
    file_path : str
        The file path to analyze.

    Returns
    -------
    namedtuple or None
        A namedtuple called with the file path elements:
        (anchor, name, stem, suffix, ancestors) if valid, or None
        if the file path is invalid.

    Examples
    --------
    >>> analyze_file_path('/user/folder/file.txt')
    FilePathElements(anchor='/', name='file.txt', stem='file',
                     suffix='.txt', ancestors=['/user/folder', '/user', '/'])
    """
    raise NotImplementedError("Complete this function.")
