               (if (nil? t)
                 new-t
                 (go (branch t) branch (xconj new-t branch (f (:val t))))))]
-    (go (:L t) :L (go (:R t) :R (xconj nil nil (f (:val t)))))))+    (go (:L t) :L (go (:R t) :R (xconj nil nil (f (:val t)))))))
+

  (letfn [(go [t acc]
              (if (nil? t)
                acc
                (+ (go (:L t) (inc acc)) (go (:R t) (inc acc)))))]
    (+ (go (:L t) 0) (go (:R t) 0))))
;fpins
;-----------------------------------------------------------------------

;3.26

                (let [val (:val t) new-max (if (nil? acc) val (max val acc))]
                  (max (go (:R t) new-max) (go (:L t) new-max)))))]
    (go t nil)))
;fpins - what is cumbersome here is probably necessity of covering all cases when matching
;over map but that is limitation of Clojure (or perhaps my own as I am not familiar currently
;with better options) as Scala variant of FPINS is utilizing matching over two case classes which
;are extending same Trait. Nevertheless, here it is, how I translated it
;not though that order of patterns here matters very much as e.g. pattern {:val :L l :R r} captures
;when l and r are nils as well so explicit match of nil must come before
(defn t-max-fpins [t]
  (match t
         {:val v :L nil :R nil} v
         {:val v :L nil :R r} (max v (t-max-fpins r))
         {:val v :L l :R nil} (max v (t-max-fpins l))
         {:val v :L l :R r}  (max v (t-max-fpins l) (t-max-fpins r))))
;-----------------------------------------------------------------------

;3.27
