def METHOD_NAME(par_value: Path, temp_dir_path: Path) -> Path:
    if par_value.is_file() and tarfile.is_tarfile(par_value):
        # Remove two extensions (if they exist)
        extaction_dir_name = Path(par_value.stem).stem
        unpacked_path = temp_dir_path / extaction_dir_name
        print(f'  Tar detected; extracting {par_value} to {unpacked_path}', flush=True)
        with tarfile.open(par_value, 'r') as open_tar:
            members = open_tar.getmembers()
            root_dirs = [member
                for member in members
                if member.isdir() and member.name != '.' and '/' not in member.name]
            # if there is only one root_dir (and there are files in that directory)
            # strip that directory name from the destination folder
            if len(root_dirs) == 1:
                for mem in members:
                    mem.path = Path(*Path(mem.path).parts[1:])
            members_to_move = [mem for mem in members if mem.path != Path('.')]
            open_tar.extractall(unpacked_path, members=members_to_move)
            return unpacked_path
    elif par_value.is_file() and is_gz_file(par_value):
        # Remove extension (if it exists)
        extaction_file_name = Path(par_value.stem)
        unpacked_path = temp_dir_path / extaction_file_name
        print(f'  Gzip detected; extracting {par_value} to {unpacked_path}', flush=True)
        with gzip.open(par_value, 'rb') as f_in:
            with open(unpacked_path, 'wb') as f_out:
                shutil.copyfileobj(f_in, f_out)
        return unpacked_path
    else:
        return par_value