How to retrieve the clustering results of rpart
I found an answer to my question using the package partykit, I post it to help others.

tree_party &lt;- as.party(tree) #coercing the rpart.object into partykit

tree_fit &lt;- fitted(tree_party) #a two-column data.frame with the fitted node numbers and the observed responses on the training data.

tree_pred &lt;- predict(tree_party, newdata = data, type = "node")