Removed duplicated code from HiierarchyType and HierarchyTypeMetaclass