I suggest to make in in steps.
First step:
Wait for the last video in playlist:
By text:
last_video = driver.find_element_by_css_selector("#secondary .index-message.style-scope.ytd-playlist-panel-renderer:nth-child(1)").text == "10 /10"
Or by waiting for the last element in the playlist directly:
last_video = driver.find_element_by_css_selector("#secondary #items>.style-scope.ytd-playlist-panel-renderer:last-of-type").get_attribute("selected")
Second step:
After the first condition is true, wait for this video to finish, with this locator (Replay button)
video_ends = driver.find_element_by_css_selector(".ytp-chrome-controls button[title=Replay]")
For this you'll need to import:
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
And use it like this:
wait = WebDriverWait(driver, timeout_in_seconds)
wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#secondary .index-message.style-scope.ytd-playlist-panel-renderer:nth-child(1)").text == "10 /10")))
Timeout will depend of the length of playlist.
It is not a quick task, nobody will agree to finish it for you here.