def existing_prefix(self, obj: Any) -> Lens:
        """Get the Lens representing the longest prefix of the path that exists
        in the given object.
        """

        last_lens = Lens()
        current_lens = last_lens

        for i, step in enumerate(self.path):
            last_lens = current_lens
            current_lens = current_lens._append(step)
            if not current_lens.exists(obj):
                return last_lens

        return current_lens
Get the Lens representing the longest prefix of the path that exists
        in the given object.
        
src/core/trulens/core/utils/serial.py