path_to_location now returns 404 on orphaned items. Resolves LMS-9661.

This resolves [LMS-9661](https://openedx.atlassian.net/browse/LMS-9661): AttributeError in jump_to_id.

The issue was that orphaned items could be matched, and because they are orphaned, no path to a parent course could be made. This patch should both fix the issue and provide a test to make sure it does not recur.

This is my first pull request. I have pre-emptively sent in my contributor agreement. Thanks in advance!

Internal reference: @antoviaque
Updated, as mentioned in the main comment thread.