element: Rewrite 'dependencies()' to be more optimal

This reduces the number of comparison we need to make and reduces
the runtime cost of this method by roughly 25%
1 file changed