Adding findMatch function that searches for any valid match by the given
template.