docs: 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