Factored out bayesnetsampler from bayesnetcpd