Implement a function to find the diameter of a binary tree.
Use a TreeNode with val, left, and right attributes. Return the diameter as the number of edges on the longest path between any two nodes. The input root may be None. For examples and tests, trees are shown in level-order form, with null representing missing children.
def diameter_of_binary_tree(root):