Let us create Binary Tree shown in above example
root = newNode ( 1 ) NEW_LINE root . left = newNode ( 12 ) NEW_LINE root . right = newNode ( 13 ) NEW_LINE root . right . left = newNode ( 14 ) NEW_LINE root . right . right = newNode ( 15 ) NEW_LINE root . right . left . left = newNode ( 21 ) NEW_LINE root . right . left . right = newNode ( 22 ) NEW_LINE root . right . right . left = newNode ( 23 ) NEW_LINE root . right . right . right = newNode ( 24 ) NEW_LINE root . right . left . left . left = newNode ( 1 ) NEW_LINE root . right . left . left . right = newNode ( 2 ) NEW_LINE root . right . left . right . left = newNode ( 3 ) NEW_LINE root . right . left . right . right = newNode ( 4 ) NEW_LINE root . right . right . left . left = newNode ( 5 ) NEW_LINE root . right . right . left . right = newNode ( 6 ) NEW_LINE root . right . right . right . left = newNode ( 7 ) NEW_LINE root . right . right . right . right = newNode ( 8 ) NEW_LINE x = root . right NEW_LINE print ( " The ▁ closest ▁ leaf ▁ to ▁ the ▁ node ▁ with ▁ value " , x . key , " is ▁ at ▁ a ▁ distance ▁ of " , minimumDistance ( root , x ) ) NEW_LINE