I think with (a lot) more memory it would/should work.
I can’t follow the exact details, but it looks to me as if the relationship should look like the attached diagram. That is a very bad paintshop join of two relationships, from Terkal to each of your grandfathers. If it is correct, then the links are very simple, and should (in English) be something like ninth-cousins, or similar.
In that case, I would like to try and find out (from Richard Cisee who wrote this code) why it doesn’t work. Have you tried it with more memory? Perhaps on a local installation where you can give it as much memory as it needs? I could try that (in a few days) if you don’t mind me grabbing a copy of your GEDCOM file temporarily.