code: protected FlowElement getCurrentFlowElement(final ExecutionEntity execution) {
      if (execution.getCurrentFlowElement() != null) {
        return execution.getCurrentFlowElement();
      } else if (execution.getCurrentActivityId() != null) {
        String processDefinitionId = execution.getProcessDefinitionId();
        org.activiti.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(processDefinitionId);
        String activityId = execution.getCurrentActivityId();
        FlowElement currentFlowElement = process.getFlowElement(activityId, true);
        return currentFlowElement;
      }
      return null;
    }
docs: Helper method to match the activityId of an execution with a FlowElement of the process definition referenced by the execution.