Aspose.psd python text layers issues

from aspose.psd.fileformats.psd import PsdImage
from aspose.psd.fileformats.psd.layers import TextLayer
from aspose.psd import Color
from aspose.pycore import cast

psdFilePath = “template.psd”

def main():
source_file = psdFilePath
output_file = “Output.psd”

with PsdImage.load(source_file) as img:
    image = cast(PsdImage, img)
    text_layer = None

    # Define a recursive function to find TextLayer
    def find_text_layer(layers):
        for i, layer in enumerate(layers):
            print(f"Checking layer {i}: {layer}")
            if isinstance(layer, TextLayer):
                return cast(TextLayer, layer)
            elif hasattr(layer, 'layers'):
                text_layer = find_text_layer(layer.layers)
                if text_layer:
                    return text_layer
        return None

    text_layer = find_text_layer(image.layers)

    if text_layer:
        text_layer.update_text("Update", Color.red)
        image.save(output_file)
    else:
        print("Text layer not found.")

if name == ‘main’:
main()
Thats my code, just a simple program to find a text layer, unfortunaly it always returns text layer not found on my test psd that 100% includes text layers. Any ideas? Mac os sequoia 15.0.1, latest aspose version

@johnnyalki222 please use
from aspose.pycore import cast, as_of, is_assignable

 if is_assignable(layer, TextLayer):
     # do smth

If you need to find layer by its name, please use code like this:

    with PsdImage.load(source_file) as img:
        image = cast(PsdImage, img)

        for layer in image.layers:
            if layer.display_name == "Rectangle 1":
                print("Found " + layer.display_name)