Fixed bug when validating self relationship. (issue #236)