private function build(ArrayObject $select, array $fields, $prefix = null)
    {
        foreach ($fields as $name => $field) {
            if ($field['type'] === 'repeater') {
                $subField = new ArrayObject();
                $this->build($subField, $field['fields']);
                if ($prefix) {
                    $select[$prefix][$name] = iterator_to_array($subField);
                } else {
                    $select[$name] = iterator_to_array($subField);
                }

            }
            if ($field['type'] === 'block') {
                foreach ($field['fields'] as $blockName => $block) {
                    $subField = new ArrayObject();
                    $this->build($subField, $block['fields']);
                    if ($prefix) {
                        $select[$prefix][$name][$blockName] = iterator_to_array($subField);
                    } else {
                        $select[$name][$blockName] = iterator_to_array($subField);
                    }
                }
            }
            $values = $this->getValues($field);
            if ($values !== null) {
                if ($prefix) {
                    $select[$prefix][$name] = $values;
                } else {
                    $select[$name] = $values;
                }
            }
        }
    }