<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def validate_parent_id(self, key, parent_id):
 """Parent has to be different from itself."""

        id_ = getattr(self, 'id', None)
        if id_ is not None and parent_id is not None:
            assert id_ != parent_id, 'Can not be attached to itself.'
        return parent_id