public function cloneClazz(
        core_kernel_classes_Class $sourceClazz,
        core_kernel_classes_Class $newParentClazz = null,
        core_kernel_classes_Class $topLevelClazz = null
    ) {
        $returnValue = null;

        if (!is_null($sourceClazz) && !is_null($newParentClazz)) {
            if ((is_null($topLevelClazz))) {
                $properties = $sourceClazz->getProperties(false);
            } else {
                $properties = $this->getClazzProperties($sourceClazz, $topLevelClazz);
            }

            //check for duplicated properties
            $newParentProperties = $newParentClazz->getProperties(true);
            foreach ($properties as $index => $property) {
                foreach ($newParentProperties as $newParentProperty) {
                    if ($property->getUri() == $newParentProperty->getUri()) {
                        unset($properties[$index]);
                        break;
                    }
                }
            }

            //create a new class
            $returnValue = $this->createSubClass($newParentClazz, $sourceClazz->getLabel());

            //assign the properties of the source class
            foreach ($properties as $property) {
                $property->setDomain($returnValue);
            }
        }
        return $returnValue;
    }