from typing import Union
import pathlib


def create_directory(path: Union[pathlib.Path, str]) -> pathlib.Path:
    """Creates recursively the given directory under `path`.

    Args:
        path (str): Path of the directory, we want to create.

    Returns:
        pathlib.Path: The path.
    """
    path = pathlib.Path(path)
    if not path.is_dir():
        path.mkdir(parents=True, exist_ok=False)
    return path