Persistent tree using indirect Enum in swift


On my model, Categoria is a tree. I wrote the in swift like that:

    indirect enum Categoria<Elemento: Comparable> {
        case Vazio
        case No(Categoria<Elemento>, Elemento, Categoria<Elemento>)

        init() {
            self = .Vazio
        init(_ elemento: Elemento, esquerda: Categoria<Elemento> = .Vazio, direita: Categoria<Elemento> = .Vazio) {
            self = .No(esquerda, elemento, direita)

This is the basic definition. Inserts, lookups etc are written within extensions. The problem is: How can I persist a class in Realm which has one of its properties as Categoria? Oh, there’s more: How can I persist in Realm one object of Categoria?