<p>Given the <code>root</code> of a binary search tree (BST) with duplicates, return <em>all the <ahref="https://en.wikipedia.org/wiki/Mode_(statistics)"target="_blank">mode(s)</a> (i.e., the most frequently occurred element) in it</em>.</p>
<p>If the tree has more than one mode, return them in <strong>any order</strong>.</p>
<p>Assume a BST is defined as follows:</p>
<ul>
<li>The left subtree of a node contains only nodes with keys <strong>less than or equal to</strong> the node's key.</li>
<li>The right subtree of a node contains only nodes with keys <strong>greater than or equal to</strong> the node's key.</li>
<li>Both the left and right subtrees must also be binary search trees.</li>
<strong>Follow up:</strong> Could you do that without using any extra space? (Assume that the implicit stack space incurred due to recursion does not count).