diff --git a/lib/core/utils/flattened-tree.js b/lib/core/utils/flattened-tree.js index 80f977e992..4fca4c67b2 100644 --- a/lib/core/utils/flattened-tree.js +++ b/lib/core/utils/flattened-tree.js @@ -142,15 +142,13 @@ axe.utils.getNodeFromTree = function(vNode, node) { return vNode; } vNode.children.forEach(candidate => { - var retVal; - + if (found) { + return; + } if (candidate.actualNode === node) { found = candidate; } else { - retVal = axe.utils.getNodeFromTree(candidate, node); - if (retVal) { - found = retVal; - } + found = axe.utils.getNodeFromTree(candidate, node); } }); return found;