The main goal of merging two hierarchies is to preserve how chemical environments are assigned, such that the clustering of the environments does not significantly change. We aim to make the SMARTS patterns that agree, or intersect, to be higher priority over other compositions when matching chemical environments. From a force field perspective, chemical environments that match the intersection of two SMARTS patterns should also presumably have similar physical parameters. We therefore want intersecting SMARTS patterns to have the highest priority in the hierarchy. The two hierarchies are composed using the Cartesian product of the nodes in the hierarchies and are composed with several BESMARTS operations. In order from ascending priority, we first take the original hierarchies, then the left conditional difference, right conditional difference, and the intersection of the two hierarchies. Conditional operations are defined in the same way as the normal operation, but handle cases where the operation results in an empty primitive, z = 0, which is not valid in the SMARTS language. To overcome this, we define the conditional operation as one where we replace any empty primitives with the value of the primitive in the left operand. For example the intersection