Derive utility function with both substitutes and complements
The general way to do this would be using a nested CES Function.  CES Wikipedia

For your example you could define the utility of sandwiches (S) and condiments (C) to be 

$$ U(D,H,M,Y) = (a_1 S^{\frac{s-1}{s}} + a_2 C^{\frac{s-1}{s}})^{\frac{s}{s-1}} $$
then you can define $S$ and $C$ "nests" as
$$ S = (b_1 D^{\frac{\rho-1}{\rho}} + b_2 H^{\frac{\rho-1}{\rho}})^{\frac{\rho}{\rho-1}} $$
$$ C = (c_1 M^{\frac{\eta-1}{\eta}} + c_2 Y^{\frac{\eta-1}{\eta}})^{\frac{\eta}{\eta-1}} $$

$s$ determines whether S and C are complements ($s \rightarrow 0$) or substitutes ($s \rightarrow \infty$), or neither ($s=1$).

The same holds for $\rho$ and $\eta$ in the "nests".  $a$, $b$, and $c$ establish the relative importance of each item within a nest. 

Extending this to $N$ you can have an arbitrary number of nests and an arbitrary number of elements within each nest.  This way may look complicated, but it has a lot of flexibility and gives you nice derivatives when solving maximization problems.