Relative entropy via non-sequential recursive pair substitution