Add backport of gnulib git commit 4c1009ec93e12ee34acd27f6d7e25442bedc16f2.
When the file found in a PATH element is a directory, continue searching.
PR: 246615
Submitted by: jkim
Obtained from: https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=4c1009ec93e12ee34acd27f6d7e25442bedc16f2