Fundamentally, the quantity units are a graph. Valid QUs for a given product are all QUs that have a path to the stock QU or the Purchase QU.
Structure-wise, the QUs and their conversions form a graph with n weakly connected components; with the QUs as Vertices and the conversions as Edges. All valid conversions for a QU are the outgoing edges of the transitive hull of the aforementioned QU graph.
This transtive hull should also be used to prohibit cycles in the graph. However, this isn't enforced by the current code. For the moment, we just accept this, but this is a big TODO.