Empty targets are also a problem for the substructure search. Simple checks avoids the infinite loop.

Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>