import sklearn.tree
clf = sklearn.tree.DecisionTreeClassifier()
clf.fit(X, y)
clf.tree_.apply(np.asfortranarray(X.astype(sklearn.tree._tree.DTYPE)))
Using scikit-learn DecisionTreeClassifier to cluster