Find the parent node type of the commerce product being added to the cart
Generally speaking, the line item for each product in the cart has a data array with a context sub-array that includes information identifying the context from which the product was added to the cart. In the case of a product added from a node's Add to Cart form, this array would point to the specific node ID and even name the reference field responsible for generating the form.

If I were you, I'd use the Devel module's dpm() function to inspect the contents of the line item's data array. Drilling down through the context array you should discover how to get the information you're needing. Just make sure to use a !empty() check before assuming a particular key in the array exists!