May I ask how big is the tree? If space is not an issue and if just want fastest way, maybe just use a hash table to store each node link with all parents as a comma delimited string, just one hash lookup and a text search on the csv will get the answer