revisions to main recursive tree mining fn [ci skip]