public function replaceAll($targets) {
    if ($targets instanceof Node) {
      $targets->replaceWith($this->nodes);
    }
    elseif ($targets instanceof NodeCollection || is_array($targets)) {
      $first = TRUE;
      /** @var Node $target */
      foreach ($targets as $target) {
        $target->replaceWith($first ? $this->nodes : clone $this);
        $first = FALSE;
      }
    }
    return $this;
  }