About distance L+1 and L

Can you explain step by step(1,2,3… steps) in the fig how algorithms works ?

code : https://www.geeksforgeeks.org/print-nodes-distance-k-given-node-binary-tree/