Programmatically Duplicate EntityQueues I'm attempting to create a duplicate of an entity queue that includes all the nodes inside it.

Here is my current code

$entityQueueId = 'hero_images';
$langcode = 'test'
$clones = [];
$subqueue = \Drupal::entityTypeManager()-&gt;getStorage('entity_subqueue')-&gt;load($entityQueueId);
$nodes = $subqueue-&gt;get('items')-&gt;referencedEntities();
    foreach ($nodes as $node) {
         $clone = $node-&gt;createDuplicate();
         $clone-&gt;title-&gt;value = $clone-&gt;title-&gt;value . ' - ' . $langcode;
         $clone-&gt;set('langcode', $langcode);
         $clone-&gt;setCreatedTime(time());
         $clone-&gt;setChangedTime(time());
         $clone-&gt;save();
         $clones[] = [
             'target_id' =&gt; $clone-&gt;id(),
         ];
    }

    $subqueue_clone = $subqueue-&gt;createDuplicate();
    $subqueue_clone-&gt;set('name', $langcode . '-' . $subqueue-&gt;id() . '-' . uniqid());
    $subqueue_clone-&gt;set('title', $langcode . '-' . $subqueue-&gt;id() . '-' . uniqid());
    $queue = $subqueue-&gt;getQueue();   
    $queue_clone = $queue-&gt;createDuplicate();
    $queue_clone-&gt;set('id', $langcode . '-' . $queue-&gt;id() . '-' . uniqid());
    $queue_clone-&gt;set('title', $langcode . '-' . $queue-&gt;id() . '-' . uniqid());
    $queue_clone-&gt;save();
    $subqueue_clone-&gt;setQueue($queue_clone);
    $subqueue_clone-&gt;set('items', $clones);
    $subqueue_clone-&gt;save();


The queue does get created, but there are no items within it. In case there was an issue with my node duplication code as a test I just set 

$subqueue_clone->set('items', $subqueue->get('items')->getValue());

but that didn't work either. Is there an issue with my code? Or should I go about this in a completely different manner? What's the best way to duplicate an entityqueue while preserving or duplicating the list of the nodes inside it?
I was able to get it to work, but I'm not entirely sure why it works. What I did was after saving the duplicated subqueue I loaded it once again then applied the items before saving for a second time. 

    $subqueue_clone-&gt;save();
    $newsubqueue_clone = \Drupal::entityTypeManager()-&gt;getStorage('entity_subqueue')-&gt;load($clone_id);
    $newsubqueue_clone-&gt;set('items', $clones);
    $newsubqueue_clone-&gt;save();