Splunk Interview Question

design an algorithm to determine king/queen royalty lineage