how to expand all nested elements in filter

how to expand all nested elements in filter

I am trying to create a script that will open both the parent and child that matches a search.

What I want to achieve: http://prntscr.com/7gnnti Notice how the search matches children in both parents, and both parent and child are expanded.

Here is the code that I have so far, which only expands the parent http://jsfiddle.net/fishinapond/zr3aoh2r/1/#&togetherjs=xaNrc0NQNm