refactor add_nodes and max_depth for bintree