check for fileexist before traversing a directory

Change-Id: I23160d06b682b8d74923cdb12277bfa5da712607