matchNodes function

Matches nodes between two trees