clean up search results tree building code #1147