def METHOD_NAME(ctx, cli_obj, export, db, verbose_flag, timestamp, theme):
    """Find orphaned photos in a Photos library"""
    verbose_ = verbose_print(verbose=verbose_flag, timestamp=timestamp, theme=theme)
    # below needed for to make CliRunner work for testing
    cli_db = cli_obj.db if cli_obj is not None else None
    db = get_photos_db(db, cli_db)
    if not db:
        echo(get_help_msg(METHOD_NAME), err=True)
        echo("\n\nLocated the following Photos library databases: ", err=True)
        _list_libraries()
        return
    verbose_("Loading Photos database")
    photosdb = PhotosDB(dbfile=db, verbose=verbose_, rich=True)
    if photosdb.db_version <= _PHOTOS_4_VERSION:
        echo(
            "[error]Orphans can only be used with Photos libraries > version 5 (MacOS Catalina/10.15)[/]",
            err=True,
        )
        sys.exit(1)
    photos = photosdb.photos()
    photos += photosdb.photos(intrash=True)
    # need to add unselected bursts
    burst_photos = [bp for p in photos for bp in p.burst_photos]
    # will be some duplicates but those will be removed when converting to dict
    photos.extend(burst_photos)
    uuids_in_db = {photo.uuid: photo for photo in photos}
    # walk the Photos library looking for photos associated with a uuid
    uuids_in_library = {}
    verbose_("Scanning for orphan files")
    # originals
    verbose_("Scanning original files")
    directory = joinpath(photosdb.library_path, "originals")
    scan_for_files(directory, uuids_in_library)
    # edited
    verbose_("Scanning edited files")
    directory = joinpath(photosdb.library_path, "resources", "renders")
    scan_for_files(directory, uuids_in_library)
    # derivatives
    verbose_("Scanning derivative files")
    directory = joinpath(photosdb.library_path, "resources", "derivatives")
    scan_for_files(directory, uuids_in_library)
    # shared iCloud photos
    verbose_("Scanning shared iCloud photos")
    directory = joinpath(photosdb.library_path, "resources", "cloudsharing", "data")
    scan_for_files(directory, uuids_in_library)
    # shared derivatives
    directory = joinpath(
        "resources", "cloudsharing", "resources", "derivatives", "masters"
    )
    scan_for_files(directory, uuids_in_library)
    # scopes directory (Photos 7+)
    if photosdb.photos_version >= 7:
        verbose_("Scanning scopes cloudsharing files")
        directory = joinpath(
            photosdb.library_path, "scopes", "cloudsharing", "resources"
        )
        scan_for_files(directory, uuids_in_library)
        verbose_("Scanning scopes syndication files")
        directory = joinpath(photosdb.library_path, "scopes", "syndication")
        scan_for_files(directory, uuids_in_library)
        verbose_("Scanning scopes momentshared files")
        directory = joinpath(photosdb.library_path, "scopes", "momentshared")
        scan_for_files(directory, uuids_in_library)
    # find orphans
    possible_orphans = []
    for uuid, files in uuids_in_library.items():
        if uuid not in uuids_in_db:
            possible_orphans.extend(files)
    echo(
        f"Found [num]{len(possible_orphans)}[/] "
        f"{pluralize(len(possible_orphans), 'orphan', 'orphans')}"
    )
    exported = []
    for orphan in possible_orphans:
        echo(f"[filepath]{orphan}[/]")
        if export:
            dest = increment_filename(Path(export) / Path(orphan).name)
            verbose_(f"Copying [filepath]{Path(orphan).name}[/] to [filepath]{dest}[/]")
            FileUtil.copy(orphan, dest)
            exported.append(dest)
    if export:
        echo(
            f"Exported [num]{len(exported)}[/] "
            f"{pluralize(len(exported), 'file', 'files')}"
        )