;; returns the first widget for which pred returns true
(bind-func Widget_find_preorder
(lambda (widget:Widget* pred:[i1,Widget*]*)
(if (and (not (null? widget)) (pred widget))
widget
(if (not (null? widget))
(begin
(let ((left:Widget* (Widget_find_preorder (Widget_left_child widget) pred)))
(if (not (null? left))
left
(Widget_find_preorder (Widget_right_child widget) pred))))
null))))