public function addElement(FieldsetInterface &$form, $name, $data)
    {
        if ($data['type'] == 'fieldset') {
            $fieldset = new Fieldset(['name' => $name]);
            foreach ($data['elements'] as $key => $def) {
                $this->addElement($fieldset, $key, $def);
            }
            $form->add($fieldset);
        } else {
            if (array_key_exists($data['type'], static::$_elementAlias)) {
                $class = static::$_elementAlias[$data['type']];
            } else if (
                is_subclass_of($data['type'], 'Slick\Form\ElementInterface')
            ) {
                $class = $data['type'];
            } else {
                throw new Exception\UnknownElementException(
                    "'{$data['type']}' is not a known alias or an implementation of " .
                    "Slick\\Form\\ElementInterface interface"
                );
            }

            /** @var Element $element */
            $element = new $class(['name' => $name]);

            if (isset($data['input'])) {
                $element->input = InputFilterFactory::createInput(
                    $data['input'],
                    $element->getName()
                );
            }

            if (!empty($data['validate'])) {
                $this->addValidation($element, $data['validate']);
            }

            foreach (array_keys($this->_elementProperties) as $key) {
                if (isset($data[$key])) {
                    $element->$key = $data[$key];
                }
            }

            $form->add($element);
        }
    }