replaces custom recursion with native javascript query selector