Fix element/type nameclash

If a type has the same name as an element the element may be returned when we are in fact looking for the type.

This fix ensures that we only return simple or complex type nodes.

Also simplified identification boolean flow and clean up documentation a bit.