public function toDTO($filterByKey = null)
    {
        $dtos = [];
        foreach ($this->getAttributes() as $attrib => $data) {

            $attribDTO = $data; // default (unparsed or scalar)

            // we may need to parse the attribute relation or use
            // the model to get the subordinated Data Transfer Object.
            if ($data instanceof DataTransferObject || $data instanceof ModelCollection) {
                // sub DTO convert to array
                $attribDTO = $data->toDTO();
            }
            elseif (in_array($attrib, $this->relations) || method_exists($this, $attrib)) {
                // unparsed sub DTO passed - parse the DTO to make sure
                // we are working with NEM *NIS compliant* objects *always*.
                $related   = $this->resolveRelationship($attrib, $data);
                $attribDTO = $related->toDTO();
            }

            $dtos[$attrib] = $attribDTO;
        }

        if ($filterByKey && isset($dtos[$filterByKey]))
            return $dtos[$filterByKey];

        return $dtos;
    }