<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _analyze_tree(self, tree):
 """Analyze given tree and create mapping of indexes to character addresses. """

        addresses = []
        for text in self._iter_texts(tree):
            for i, char in enumerate(text.content):
                if char in whitespace:
                    char = ' '
                addresses.append(CharAddress(char, text.element, text.attr, i))

        # remove leading and trailing whitespace
        while addresses and addresses[0].char == ' ':
            del addresses[0]
        while addresses and addresses[-1].char == ' ':
            del addresses[-1]

        return addresses