from typing import Iterable
from pathlib import Path
from typing import Optional


def searchcandidates(candidates: Iterable[Path]) -> Optional[Path]:
	""" Searches for the first filename in `candidates` which exists. Returns `None` if none of the paths are valid.
		Parameters
		----------
		candidates: List[Path]
			The filenames to test.
	"""
	for candidate in candidates:
		if candidate.exists():
			return candidate