Factor this pattern out into a method `copyOfOrEmpty`, or something like that?