Cleanup the resource getnodes processor

Prior to this cleanup, due to an issue with ltrim(), it was impossible for custom resources to use a custom icon. After this cleanup that ability is restored through a system setting (that 3PCs need to provide) of mgr_tree_icon_<CLASS_KEY> where <CLASS_KEY> is a lowercase representation of the class key with, if applicable, the "mod" prefix removed.

On top of that, this clean up also resolves duplicate classes being assigned to the icon. It also improves the readability and fixes some weird and/or duplicated logic.