The moodle-course-categoryexpander YUI module must be rewritten to remove the YUI.
We should be able to use the existing core/tree component, though we may need to extend that (possibly).
The core/tree component already supports dynamic loading, but is missing any animation. It is also very poorly documented, and does not have any templates associate with it. At the moment, each use of it writes its own templates.
Ideally we should be creating a reusable template and improving the component.
The current dynamic content loading is via an AMD module loaded dynamically and fetching the data.
We should perhaps look to move this to a new function which a child implementation can override.
We may want to rewrite the existing core/tree implmentation from prototypal JS into a proper class. This should be relatively easy, but we will also need to update existing extensions of this class to do the same. This will break any non-class based extensions, but in a backwards compatible way. It is possible for a class to extend a prototype, but not for a prototype to extend a class.