mypy: make get_nodes & iget_nodes more generic
Those 2 methods are called with many other classes (not only BaseNode class), so:
- add a new generic type Y to be used with get_nodes & iget_nodes methods
- rewrite get_nodes & iget_nodes methods to be more generic inside base.py