private function checkParsedObject(
        SwatUIObject $parsed_object,
        $element_name
    ) {
        if ($element_name == 'widget') {
            if (
                class_exists('SwatWidget') &&
                $parsed_object instanceof SwatWidget &&
                $parsed_object->id !== null
            ) {
                // make sure id is unique
                if (isset($this->widgets[$parsed_object->id])) {
                    throw new SwatDuplicateIdException(
                        "A widget with an id of '{$parsed_object->id}' " .
                            'already exists.',
                        0,
                        $parsed_object->id
                    );
                }
            } elseif (
                !class_exists('SwatWidget') ||
                !$parsed_object instanceof SwatWidget
            ) {
                $class_name = get_class($parsed_object);

                throw new SwatInvalidClassException(
                    "'{$class_name}' is defined in a widget element but is " .
                        'not an instance of SwatWidget.',
                    0,
                    $parsed_object
                );
            }
        } elseif ($element_name == 'object') {
            if (
                class_exists('SwatWidget') &&
                $parsed_object instanceof SwatWidget
            ) {
                $class_name = get_class($parsed_object);

                throw new SwatInvalidClassException(
                    "'{$class_name}' is defined in an object element but is " .
                        'and instance of SwatWidget and should be defined in a ' .
                        'widget element.',
                    0,
                    $parsed_object
                );
            }
        }
    }