refactoring getmodeltree to command