Add schema match for node.

@rprieto @nguyenchr please review

In addition, `validateHierarchy` function is a bit oversize. And suggestion?