Vertical only obstacle avoidance

Good evening,
Could you kindly tell me if it is somehow possible to modify the obstacle avoidance algorithm to continue on the same path after dodging an obstacle vertically similarly to the BUG2 algorithm but in the z axis or if it is somehow possible to integrate it from scratch or from another library?
Many thanks for your time and wish you all the best