Help with Related Posts Function

You can use WordPress’s tax_query arg when fetching posts to achieve what you’re trying to do, this is also easily extendable with more than one taxonomy.

$query = array(
    'post_type' => $YOUR_POST_TYPE,
    'posts_per_page' => -1 // get all
    'tax_query' => array(
        'relation' => 'OR'
    )
);

$query['tax_query'][] = array(
    'taxonomy' => 'YOUR_TAXONOMY',
    'terms' => $ARRAY_WITH_TERMS,
    'field' => 'ID',
    'operator' => 'IN'

$query['tax_query'][] = array(
    'taxonomy' => 'YOUR_TAXONOMY_2',
    'terms' => $ARRAY_WITH_TERMS_2,
    'field' => 'ID',
    'operator' => 'IN'

$posts = query_posts( $query );

Might this be what you’re looking for?