product.master is nil at the time master is creating of a particular product.

When a variant under production is itself a master, then product.master is nil in this callback.