The ProcessInstanceHistory is the object which is neither searchable nor queryable & this is the read-only object which shows all steps and pending approval requests associated with an approval process (ProcessInstance). But we can use this object to replicate the related list functionality of the Salesforce user interface for approval processes which will be shown in my next blog post soon. We can use ProcessInstanceHistory for a single read-only view of the both ProcessInstanceStep and ProcessInstanceWorkitem objects. We can query ProcessInstanceHistory by querying it in a nested soql query on the parent ProcessInstance object. The nested soql query references StepsAndWorkitems, which is the child relationship name for ProcessInstanceHistory in the ProcessInstance object. This is very useful object to solve various business problems.
~ Query ~
SELECT CompletedDate, CreatedById, CreatedDate,Id,IsDeleted,LastActorId,
LastModifiedById,LastModifiedDate,ProcessDefinitionId,Status,SubmittedById
,SystemModstamp,TargetObjectId, (SELECT ID, ProcessNodeId, StepStatus,
Comments,TargetObjectId,ActorId,CreatedById,IsDeleted,IsPending,
OriginalActorId,ProcessInstanceId,RemindersSent,CreatedDate
FROM StepsAndWorkitems ) FROM ProcessInstance