Last active
November 1, 2018 18:21
-
-
Save mekhami/0bdb31708fe08ac6593f20cdc68d5c88 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const findNode = (id, group) => { | |
let stack = new Array(group) | |
while (stack.length) { | |
let node = stack.pop() | |
if (node.id === id) { return node } | |
else if (node.children && node.children.length) { | |
node.children.forEach(child => stack.push(child)) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment