implemented tree building and node learning