When using ProductUtils.copyProductNodes it is expected that all nodes are copied to the target product.
For masks, this is not working in all cases.
It fails for masks which reference a flag of a flag coding.
When the flag coding is copied the corresponding flag band is not copied.
Therefore, the expression used by the mask is not working and the mask is not copied.
Either, the method copyFlagCoding should also copy the referenced flag band or it should be done in a separate step afterwards within copyProductNodes.
It should be investigated what's the better solution. Probably the last one, because the first one alters the current behaviour and many locations might need to be updated.