Issue #17901: fix TreeBuilder construction for an explicit element_factory=None

Based on report and patch by Aaron Oakley.
3 files changed