public function getDefinitionFor(DataObject $dataObject)
    {
        if ($dataObject->hasExtension(WorkflowApplicable::class)
            || $dataObject->hasExtension(FileWorkflowApplicable::class)
        ) {
            if ($dataObject->WorkflowDefinitionID) {
                return DataObject::get_by_id(WorkflowDefinition::class, $dataObject->WorkflowDefinitionID);
            }
            if ($dataObject->hasMethod('useInheritedWorkflow') && !$dataObject->useInheritedWorkflow()) {
                return null;
            }
            if ($dataObject->ParentID) {
                return $this->getDefinitionFor($dataObject->Parent());
            }
            if ($dataObject->hasMethod('workflowParent')) {
                $obj = $dataObject->workflowParent();
                if ($obj) {
                    return $this->getDefinitionFor($obj);
                }
            }
        }
        return null;
    }