The native nextElementSibling only looks within the same parent, which is why this problem is harder. You are tasked with creating a function findNextRightSibling that identifies the next right sibling of a given node within a tree structure, resembling the DOM tree. This function should traverse the tree in a breadth-first manner, using a queue to keep track of the nodes.The function findNextRightSibling takes two arguments:
root: The root node of the tree from which the search begins.target: The node for which you want to find the next right sibling.
The goal is to find and return the node that is the immediate right sibling of the target node. If the target node is the last child of its parent or does not have any right siblings, the function should return null.
This functionality is crucial for applications that need to understand or manipulate hierarchical structures similar to the DOM, where knowing a node’s relationship to its siblings can influence layout, styling, or interactivity.
