protected function flattenParts(array $parts, array $flattened = [], $pre = '', $idx = 1, $full = true)
    {
        foreach ($parts as $part) {
            $key = $pre.$idx;
            $flattened[$key] = $part;
            if (isset($part->parts)) {
    			if ($part->type == TYPEMULTIPART) {
    				$flattened = $this->flattenParts($part->parts, $flattened, $key.'.', 1, false);
    			} elseif ($full) {
    				$flattened = $this->flattenParts($part->parts, $flattened, $key.'.');
    			} else {
    				$flattened = $this->flattenParts($part->parts, $flattened, $pre);
    			}
    			unset($flattened[$key]->parts);
    		}
    		$idx++;
        }

        return $flattened;
    }