Refactor: work with Node object instead of array