When you query for HistoryActivityInstance and the instance is of type task it will return HistoryTaskInstanceImpl which has a method getHistoryTask.
That (in theory) should do what you expect, but I have not tried that if it works properly or not. Let us know the result of your test.