public function insert($data, $weight = 0)
    {
        if ($this->isEmpty()) {
            $this->_nodes[] = ['data' => $data, 'weight' => $weight];
            return $this;
        }

        $inserted = false;
        $new = [];
        while(count($this->_nodes) > 0) {
            $element = array_shift($this->_nodes);
            if (
                !$inserted &&
                $this->compare((int) $weight, $element['weight']) <= 0
            ) {
                $new[] = ['data' => $data, 'weight' => (int) $weight];
                $new[] = ['data' => $element['data'], 'weight' => $element['weight']];
                $inserted = true;
            } else {
                $new[] = ['data' => $element['data'], 'weight' => $element['weight']];
            }
        }
        if (!$inserted) {
            $new[] = ['data' => $data, 'weight' => $weight];
        }
        $this->_nodes = $new;
        return $this;
    }