gh-35156: Fix index out of range exception (#35031)
### 📚 Description
We return False if there is no n-th path
Closes #35031
### 📝 Checklist
<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
- [X] I have made sure that the title is self-explanatory and the
description concisely explains the PR.
- [X] I have linked an issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.
URL: https://github.com/sagemath/sage/pull/35156
Reported by: Andrew
Reviewer(s): Sébastien Labbé