class DASpecification {

    public static List<TArtifactType> getArtifactTypeHierarchy(TArtifactType artifactType) {

        List<TArtifactType> artifactTypeHierarchy = new ArrayList<>();

        TArtifactType basisArtifactType = artifactType;
        artifactTypeHierarchy.add(basisArtifactType);

        while (basisArtifactType != null) {
            if (basisArtifactType.getDerivedFrom() != null) {
                QName parentArtifactTypeQName = basisArtifactType.getDerivedFrom().getTypeRef();
                ArtifactTypeId parentArtifactTypeId = new ArtifactTypeId(parentArtifactTypeQName);
                basisArtifactType = RepositoryFactory.getRepository().getElement(parentArtifactTypeId);
                artifactTypeHierarchy.add(basisArtifactType);
            } else {
                basisArtifactType = null;
            }
        }

        return artifactTypeHierarchy;
    }

}