from pathlib import Path


def is_illegal_dir(d: Path):
    """Refuse to remove directories for some situations, for safety.
    """
    if (d / ".git").exists():
        return ".git file found"
    if d.absolute() == Path.home().absolute():
        return "cannot replace home directory"
    if d.absolute == Path("/").absolute():
        return "cannot replace root directory"
    return None