clojure: complete rewrite of the recursive classification function