def METHOD_NAME(
    path: Optional[str] = None, prefix_search: bool = False
) -> "Transport":
    if path is None:
        try:
            return next(iter(enumerate_devices()))
        except StopIteration:
            raise TransportException("No Trezor device found") from None
    # Find whether B is prefix of A (transport name is part of the path)
    # or A is prefix of B (path is a prefix, or a name, of transport).
    # This naively expects that no two transports have a common prefix.
    def match_prefix(a: str, b: str) -> bool:
        return a.startswith(b) or b.startswith(a)
    LOG.info(
        "looking for device by {}: {}".format(
            "prefix" if prefix_search else "full path", path
        )
    )
    transports = [t for t in all_transports() if match_prefix(path, t.PATH_PREFIX)]
    if transports:
        return transports[0].find_by_path(path, prefix_search=prefix_search)
    raise TransportException(f"Could not find device by path: {path}")