jackknife tree script rewrite