Thanks for your reply, I think I found an easier way to do what I need. I found a related post plugin that lets you export Post IDs:
$rel_posts = get_crp_posts_id(array ('postid' => $post_id, 'limit' => 4));
Is there a way to implement this into the snippet you posted earlier? It should give out 4 ID’s that WPSP could output, right? If that’s possible I wouldn’t need any of the other conditions.