Fix bug in path calculation - exponential recursion call.
Store calculated path in @path, which give 2 times faster documents
rendering in our tests.

tnx to Dmitry Lavrov