I've a flat structure where a node references its parent instead of children
class Node(int Id, Node Parent, string Data);
Given a list of all nodes, and a search condition, I want to return the matches plus all ancestors and descendants
This what I'm trying to implement https://hshn.github.io/angular-ui-tree-search/
What would be a reasonably efficient algorithm to achieve this? I was aiming to build a tree as described here https://stackoverflow.com/questions/444296/how-to-efficiently-build-a-tree-from-a-flat-structure, and replicate the algorithm from the angular library above but it went over my head with all that OOP'ness