If vs. while in specific JavaScript code
<p>Why does the author of <em>Test-Driven JavaScript Development</em> (Christian Johansen) use the <code>while</code> statement instead of the <code>if</code> statement in the code below?</p>

<pre><code>function getEventTarget(event) {
    var target = event.target || event.srcElement;

    while (target &amp;&amp; target.nodeType != 1) {
        target = target.parentNode;
    }

    return target;
}
</code></pre>
