public function addSub($sub, $key, $value)
    {

        // Nothing of this type yet, set an empty array
        if (!isset($this->result[$sub]) or !is_array($this->result[$sub])) {
            $this->result[$sub] = [];
        }

        // Find the first entry that doesn't have this variable
        $found = false;
        for ($i = 0; $i != count($this->result[$sub]); $i++) {
            if (!isset($this->result[$sub][$i][$key])) {
                $this->result[$sub][$i][$key] = $value;
                $found = true;
                break;
            }
        }

        // Not found, create a new entry
        if (!$found) {
            $this->result[$sub][][$key] = $value;
        }
    }