This commit has a small refactor of some methods in create_url_tree.ts and adds some test cases, including two that will fail at the moment but should pass. A follow-up commit will make use of the refactorings to fix the test with minimal changes. PR Close #39456