refactored get_latest_undeleted_pid to not blindly call getPostsByTid in
order to determine post deletion. (issue #320)