Refactored the markOccurrences code

Find the identifier using traversal and Stop traversal on finding the identifier

Signed-off-by: Lakshmi Shanmugam <lshanmug@in.ibm.com>