from pathlib import Path


def relative_path_for(provided_path: Path, root_path: Path) -> Path:
    """
    Return relative path to root is provided path is on root_path, If not return the provided path

    Parameters
    ----------
    provided_path : Path
        absolute or relative path
    root_path : Path
        absolute path the relative path will stem from

    Returns
    -------
    Path
        relative path if provided_path is relative or provided_path is on root_path.  Else will return
        the provided_path which will be an absolute path.

    """
    if provided_path.is_absolute():
        if provided_path == root_path:
            return provided_path

        if provided_path.is_relative_to(root_path):
            return provided_path.relative_to(root_path)

    return provided_path