The question was simple but we spent some time trying to understand what they were asking. Basically you had to calculate the number of common ancestors between the two nodes.
https://github.com/diofeher/ctf-writeups/blob/master/2018-12-01-pwn2win/bavarian.py