we could implement such encoder / decoder in eg circe somewhat like:
implicit def decoderForAOrNodeA[A: Decoder]: Decoder[A Or Node[A]] =
Decoder[A].map(OrLeft).or(Decoder[Node[A]].map(OrRight))
implicit def encoderForAOrNodeA[A: Encoder]: Encoder[A Or Node[A]] = {
case OrLeft(a) => a.asJson
case OrRight(aNode) => aNode.asJson
}