// k2 semi-recursive / paths to leaves (recursive) pl:{{:[5=4:y;,/(x,/:!y)_f'y[];,x]}[();x]} / subtree where leaf x is f x (non-recursive) st:{[t;f] / subtree of t where leaves are f p:pl t / paths to leaves d:t ./:p / data at leaves i:&f d / where leaves are f ./[.();p i;:;d i]} / subtree / pretty-print (recursive) pp:{`0:{:[5=4:y;,/(x$!y){(,x),y}'(1+x)_f'y[];,(1+x)$y]}[1;x]} \ / tree t[`a;`b`c`d;`e`f]:3 2_draw 100 / print t pp t a b e 31 f 51 c e 29 f 35 d e 17 f 89 / subtree where 50