code: def previous_sibling(self):
          if self.parent:
              nodes = self.parent.children
              index = nodes.index(self)
              sibling = nodes[index - 1] if index > 0 else None
          else:
              nodes = self.tree.nodes
              index = nodes.index(self)
              sibling = (
                  next((n for n in reversed(nodes[:index]) if n.level == self.level), None)
                  if index > 0 else None
              )
          return sibling