Optimized finding definition nodes to search for correct element type.