DRY up getting index path of next or previous rows