Union Find Algorithms using Nodejs