Implementing a decision tree from scratch