rewrite labeltree_predict into cpp