Rational nested set tree encoder