protected function loadLastObject($type, $sortkeyName, $sortDirection) {
    $query = new ObjectQuery($type);
    $pagingInfo = new PagingInfo(1, true);
    $invSortDir = $sortDirection == 'ASC' ? 'DESC' : 'ASC';
    $objects = $query->execute(BuildDepth::SINGLE, [$sortkeyName." ".$invSortDir], $pagingInfo);
    return sizeof($objects) > 0 ? $objects[0] : null;
  }