from typing import Union
from typing import Optional
from pathlib import Path


def check_for_project(path: Union[str, "Path"] = ".") -> Optional["Path"]:
    """Checks for a Brownie project."""
    path = Path(path).resolve()
    for folder in [path] + list(path.parents):
        if folder.joinpath("brownie-config.json").exists():
            return folder
    return None