def METHOD_NAME(
        locations: typing.Iterable[typing.Optional[str]],
        names: typing.Iterable[str],
) -> typing.Generator[str, None, None]:
    """Build candidate names."""
    for location in locations:
        if not location:
            continue
        if location == '__PATH__':
            yield from build_path_candidates(names)
        elif os.path.isfile(location):
            yield location
        elif os.path.isdir(location):
            for name in names:
                cmd = os.path.join(location, name)
                if os.path.isfile(cmd):
                    yield cmd