from pathlib import Path


def convert_to_valid_path(filepath: str) -> Path:
    """
    Remove a root path prefix "/", and a relative path "." and "..".
    :param filepath:
    :return:
    """
    valid_factors = [factor for factor in filepath.split(
        "/") if factor and factor != ".."]
    return Path(*valid_factors)