'Check this object for internal consistency.
:raise ObjectFormatException: if the object is malformed in some way'

def check(self):

    super(Tree, self).check()
    last = None
    allowed_modes = ((stat.S_IFREG | 493), (stat.S_IFREG | 420), stat.S_IFLNK, stat.S_IFDIR, S_IFGITLINK, (stat.S_IFREG | 436))
    for (name, mode, sha) in parse_tree(''.join(self._chunked_text), True):
        check_hexsha(sha, ('invalid    sha    %s' % sha))
        if (('/' in name) or (name in ('', '.', '..'))):
            raise ObjectFormatException(('invalid    name    %s' % name))
        if (mode not in allowed_modes):
            raise ObjectFormatException(('invalid    mode    %06o' % mode))
        entry = (name, (mode, sha))
        if last:
            if (key_entry(last) > key_entry(entry)):
                raise ObjectFormatException('entries    not    sorted')
            if (name == last[0]):
                raise ObjectFormatException(('duplicate    entry    %s' % name))
        last = entry
