public function removePart(MessagePart $part)
    {
        $parent = $part->getParent();
        if ($this !== $parent && $parent !== null) {
            return $parent->removePart($part);
        } else {
            $position = array_search($part, $this->children, true);
            if ($position !== false && is_int($position)) {
                array_splice($this->children, $position, 1);
                $this->onChange();
                return $position;
            }
        }
        return null;
    }