2d sprites layering v3.8(z Index)

Hello. I know there is the siblingIndex property. But that is not what i am looking for. The issue i am facing is here

As you see the white square is under the trees. But it must be under only when its Y position is higher that the Y position of a tree.

So the idea is the lower the Y pos the higher the zIndex.

In v2.4 i could use the zIndex to achieve this. In the update function of a node i did something like this:

this.node.setPosition(
    this.node.position.x + direction.x * moveSpeed,
    this.node.position.y + direction.y * moveSpeed
)
this.node.zIndex = cc.macro.MAX_ZINDEX - this.node.position.y;

And it worked fine. But now we don’t have this property. Using siblingIndex is really not a good idea to achieve what i want because it depends on count of children. I can not use random values to change siblingIndex as i can do it in 2.4 with zIndex. Now it means that in the update function i must find the closest node to my node by Y position and change the siblingIndex. Sounds not good to use the find function in the update function. I have a lot of nodes on the scene.

Does anybody have an idea how to achieve the same thing like in 2.4?