Added an extra parameter to functions used for result generation to obtain match function, removed the implicit traversal of node when a function is used instead of pattern for result and added check to let exception through that are errors not related to the pattern matching algorithm