protected function _addJoinClause(Zend_Db_Select $select, array $related, $rule = null,
        $bindingModel = null, $bidirectional = true
    ) {
        foreach ($related as $filterModelName => $filterValue) {
            $fieldInfo = explode('.', $filterModelName, 2);
            $filterModelName = Garp_Content_Api::modelAliasToClass($fieldInfo[0]);

            $filterColumn = $fieldInfo[1];
            $filterModel = new $filterModelName();
            /**
             * Determine wether a negation clause (e.g. !=) is requested
             * and normalize the filterColumn.
             */
            $negation = strpos($filterColumn, '<>') !== false;
            $filterColumn = str_replace(' <>', '', $filterColumn);

            if ($filterModelName === get_class($this->_model)) {
                /*  This is a homophile relation and the current condition touches the
                    homophile model.
                    The following condition prevents a 'relatable' list to include the
                    current record, because a record cannot be related to itself.
                */
                $select->where(
                    $this->_getTableName($filterModel) . '.' . $filterColumn . ' != ?',
                    $filterValue
                );
            }

            try {
                // the other model is a child
                $reference = $filterModel->getReference(get_class($this->_model), $rule);
                $this->_addHasManyClause(
                    array(
                    'select'        => $select,
                    'filterModel'   => $filterModel,
                    'reference'     => $reference,
                    'filterColumn'  => $filterColumn,
                    'filterValue'   => $filterValue,
                    'negation'      => $negation
                    )
                );
            } catch (Zend_Db_Table_Exception $e) {
                try {
                    // the other model is the parent
                    $reference = $this->_model->getReference(get_class($filterModel), $rule);
                    $this->_addBelongsToClause(
                        array(
                        'select'        => $select,
                        'reference'     => $reference,
                        'filterColumn'  => $filterColumn,
                        'filterValue'   => $filterValue,
                        'negation'      => $negation
                        )
                    );
                } catch (Zend_Db_Table_Exception $e) {
                    try {
                        // the models are equal; a binding model is needed
                        $this->_addHasAndBelongsToManyClause(
                            array(
                            'select'        => $select,
                            'filterModel'   => $filterModel,
                            'filterColumn'  => $filterColumn,
                            'filterValue'   => $filterValue,
                            'negation'      => $negation,
                            'bindingModel'  => $bindingModel,
                            'bidirectional' => $bidirectional
                            )
                        );
                    } catch (Zend_Db_Table_Exception $e) {
                        throw $e;
                    }
                }
            }
        }
    }