Filter an n-ary tree by substring and render it indented
Each node of an n-ary tree has a string value and a list of children.
- Given a search string, return the filtered tree: keep every node whose value contains the substring, plus the ancestors needed to reach it; drop everything else.
- Render the (filtered) tree in a UI with indentation by depth, and update it as the user types in a filter box.
No answer yet. Write the first one; the best answer gets endorsed.