Extract nest path calculation to separate method

To reduce complexity.