import tarfile


def extract_tarfile(file_path):
    """Extract a .tar archive into an appropriately named folder, return the path of the folder, avoid extracting if folder exists."""
    new_path = None
    with tarfile.open(str(file_path)) as archive:
        new_dir = file_path.name.split('.tar')[0]
        new_path = file_path.parent / new_dir
        if not new_path.exists():
            archive.extractall(str(new_path))

    return new_path