Add priority-ordered search to pattern matcher.

Search can be truncated or prioritized with this new callback.
Merge pull request #749 from linas/prio

Add priority-ordered search to pattern matcher.