Are there any real-life problems where a generic binary tree like this would be best? We already have dicts and sets and the heapq module, and you can check out sortedcontainers on PyPI if you need fast data structures that maintain sort order.
I don’t think it’s worth including something in the standard library purely based on theoretical or CS-pedagogical reasons. We don’t need separate implementations of heapsort and quicksort and shellort and bubble sort, even though those are sometimes studied in CS classes. Instead, we have one method: list.sort(), and people can use it without caring how it’s implemented. The Zen of Python mentions that we should prefer having only one obvious way of doing things.
I see binary trees as a conceptual tool for implementing some data structures, but Python users shouldn’t have to care about the implementation details of the data structures they use.
I’m also worried that “binary tree” is a bit too general/vague to be useful: each application of binary trees (red-black, AVL, binary heaps, search trees, segment trees, etc.) has particular invariants and operations that it needs to maintain, and tying all of the implementations together makes it confusing what invariants actually hold. It also prevents problem-specific optimizations and design choices, like whether the tree can be stored flatly as an array or whether each node has a reference to its parent or whether a node knows its number/depth of subtree, etc. The only thing that all of these structures share is some notion of a node having left and right children, and that’s the easy part that can be re-implemented as needed.
Right; while it looks like a nice module, it’s not a good fit for the standard library.
There are also many reasons why you wouldn’t want that; for example:
Jupyter/Graphviz integration (adding these dependencies to Python’s test suite would be difficult, and we can’t support untested features)
On PyPI, you can release changes/improvements as often as you want