function filterAttributeValues( RecordSet $sourceRecordSet, Attribute $attributeAttribute, array &$attributeIds ) {
	$result = new ArrayRecordSet( $sourceRecordSet->getStructure(), $sourceRecordSet->getKey() );
	$i = 0;
	
	while ( $i < $sourceRecordSet->getRecordCount() ) {
		$record = $sourceRecordSet->getRecord( $i );
		
		if ( in_array( $record->getAttributeValue( $attributeAttribute )->definedMeaningId, $attributeIds ) ) {
			$result->add( $record );
			$sourceRecordSet->remove( $i );
		}
		else
			$i++;
	}
	
	return $result;
}