Function deriveHierarchy