Check if note is open with api

What I’m trying to do

Using the API I want to open a note in a new leaf only if it is not already open.

Things I have tried

This is how I’m opening the note

const daily = tp.file.findtfile("Daily questions.md");
await app.workspace.getLeaf(true).openFile(daily, {active: false});

What code is required to check if it is already open in a leaf?

This seems to do the job

if (app.workspace.getLeavesOfType('markdown').find(leaf => leaf.getDisplayText() == "Daily questions") == null) {
	const daily = tp.file.find_tfile("Daily questions.md");
	await app.workspace.getLeaf(true).openFile(daily, {active: false});
}