Question about implementing chained word-validation logic in Godot

I’ve encountered an odd problem with my letter-chaining logic while experimenting with a small word-puzzle prototype in Godot. Every new word should begin with the final letter of the preceding one. I wasn’t attempting to replicate the spellbeegame layout style; rather, I was looking at it to gain an understanding of how structured letter arrangements can function.

My validation isn’t acting consistently, which is the issue. Sometimes it lets through combinations that don’t adhere to my own rules, and other times it blocks perfectly valid chains. I’m also worried that when I add more words, my dictionary lookup method might not scale well.

Please share your code as preformatted text with triple backticks ``` at the beginning and end of the snippet.