Fix toHierarchy()