let filter f tree = let rec aux { content = t ; children = l } = if f t l then Some (node t (LList.filter_map aux l)) else None in LOption.unopt ~exc:Empty_tree (aux tree)