Refactoring topass by reference instead of using existing pointers.
The MaterialTreeWidget was not working in QT6 due to a type check for a QT5 widget