This line has become very complex. How would you describe its purpose and can it be factored out into a predicate method?

Is it checking for parent components of the URL?