from typing import Union
from pathlib import Path


def ensure_existing_dir(path: Union[str, Path]):
    """Ensure provided path exists and is a directory.

    Args:
        path: path to check

    Returns:
        Path: Path object.
        NoneType: If path does not exists or is not a directory
    """
    path = Path(path)
    if not path.exists():
        return None
    if not path.is_dir():
        return None
    return path