About finding all the paths between two vertex assigning the length of paths

I want to find all the paths between A and B which the length of the paths under 4, I tried the following query, but it didn’t work.

Query:

match {class:patient,where:(patientName=‘A’)}.bothE().(bothV().bothE()){while:($depth < 3)}.{class:patient,where:((patientName=‘B’)}

return $pathelements

Hi,
what version of OrientDB are you using?

Thanks
Regards,
Michela

The version is 3.0.18