def METHOD_NAME(
    self,
    relative_path: str | Path,
    root: str | Path = None,
    restrict_to_root: bool = True,
) -> Path:
    """Resolve the relative path within the given root if possible.
    Parameters
    ----------
    relative_path
        The relative path to resolve.
    root
        The root path to resolve the relative path within.
    restrict_to_root
        Whether to restrict the path to the root.
    Returns
    -------
    Path
        The resolved path.
    Raises
    ------
    ValueError
        If the path is absolute and a root is provided.
    ValueError
        If the path is outside the root and the root is restricted.
    """
    # Posix systems disallow null bytes in paths. Windows is agnostic about it.
    # Do an explicit check here for all sorts of null byte representations.
    for null_byte in self.NULL_BYTES:
        if null_byte in str(relative_path) or null_byte in str(root):
            raise ValueError("embedded null byte")
    if root is None:
        return Path(relative_path).resolve()
    self._logger.debug(f"Resolving path '{relative_path}' in workspace '{root}'")
    root, relative_path = Path(root).resolve(), Path(relative_path)
    self._logger.debug(f"Resolved root as '{root}'")
    if relative_path.is_absolute():
        raise ValueError(
            f"Attempted to access absolute path '{relative_path}' in workspace '{root}'."
        )
    full_path = root.joinpath(relative_path).resolve()
    self._logger.debug(f"Joined paths as '{full_path}'")
    if restrict_to_root and not full_path.is_relative_to(root):
        raise ValueError(
            f"Attempted to access path '{full_path}' outside of workspace '{root}'."
        )
    return full_path