function inheritedApiFields() {
    $fields     = array();
    $currentObj = $this->owner->class;

    while($currentObj != 'DataObject') {
      $apiFields  = singleton($currentObj)->stat('api_fields');
      if ($apiFields === null) {
        $apiFields = Config::inst()->get($this->owner->class, 'db', Config::INHERITED);//$this->owner->stat('db');
        $fields['ID'] = 'ID'; // we have to add manually 'ID'
        $fields['ClassName'] = 'ClassName';
        $fields['Created'] = 'Created';
        $fields['LastEdited'] = 'LastEdited';
        if (is_array($apiFields)) foreach ($apiFields as $field => $type) {
          $fields[$field] = $field;
        }
      }
      else if (is_array($apiFields)) {
        $fields = array_merge($fields, $apiFields);
      }
      $currentObj = get_parent_class($currentObj);

    }

    return array_unique($fields);
  }