You are given the roots of two binary trees, named p and q. Your task is to check whether these two trees are identical; return true if they are, otherwise return false.
Two binary trees are considered identical if they share exactly the same shape (node arrangement) and every corresponding node contains the same value.
The input for each tree is provided as a level‑order array, where integers represent node values and the special token null indicates an absent child. An empty tree is represented by an empty array [].
Example 1:
Input: p = [5,3,8], q = [5,3,8]
Output: true
Example 2:
Input: p = [2,4], q = [2,null,4]
Output: false
Explanation: In tree p, the value 4 is a left child of 2; in tree q, 4 is a right child of 2, so the structures differ.
Example 3:
Input: p = [1,2,3], q = [1,3,2]
Output: false
Explanation: The two trees have identical shapes, but the children of the root hold different values.
Example 4:
Input: p = [], q = []
Output: true
Constraints:
[0, 100].-10^4 <= Node.val <= 10^4