As the user who originally closed your question, let me explain myself, first, by addressing the points in your post here.
The question demonstrates prior research which I have done on this and
shows my attempts at solving the problem.
Indeed, credit must be given where it is due. You don't realise how refreshing it is for someone who has to deal with the daily onslaught of low effort VLQs, to see a well written, good, on topic question here. This is also why I've upvoted your question.
I believe the linked duplicate does not answer my question. Even if it
does, it only has a far resemblance to what I'm trying to solve.
On its surface, the answer in the duplicate appears to be solving a different question, but as Andras Deak so expertly worded it -
It seems to me that the accepted answer on the linked duplicate is
really what you need. The only differences are that your _end
is None
,
and that instead of looping over each character in a word you have to
loop over every item in url_path_parts
, or something similar.
So, in essence, your question has all the makings of a problem that can be best solved using a TRIE, which is why I have marked the question as such. In my opinion, it is better to be directed towards the best solution immediately, rather than face the possibility of receiving sub-par answers to your question which may or may not solve your problem as well as the target would. However, mark that there are exceptions where a particular tool has developed since the original question was asked. In this case, you may argue that your question could receive a possibly better answer than the original. Note that SO's policy on this is that the better answer should be added to the original question, to prevent fragmentation of the knowledge base.
One thing I should've done, was made it clearer how exactly the target solved your problem, and I did not make that clear to you. My apologies. I hope it's clear now.
If you agree with the question being closed, could you explain why you
think it shoud remain closed? I think it will help me ask better
questions in the future.
Never for a moment believe that there is any shame in asking a question that has already been asked before. A duplicate question acts as a signpost, directing users with the same problem (but searching with different keywords on google) to find the question that helps them the most. We welcome duplicates, as long as the questions show that the user has genuinely made an attempt to research and solve their problem first.
In summary, I believe your question was a well thought out, well researched and well written question, for which a TRIE would be the best answer, and marked as such.
No hard feelings, and I hope you will continue returning to this site to contribute with more valuable questions and answers in future.