Factorize function to extract referencedClasses out of HasClassReferences