[backport] Removed all calls to `List.head` in `StructureBuilder`

Calling `List.head` is in general a bad idea, and that alone is good enough
motivation for not doing it. Furthermore, as ticket #1001707 demonstrates, the
call to `head` can throw an exception in the `ScalaStructureBuilder`.

The exception is likely thrown for Scala sources that contain type errors,
because not all expected information may be available in some of the inspected
symbols. For instance, a class is expected to always have at least one
superclass, however if there are type errors it is possible for a class symbol
to have no superclasses, and hence accessing the `head` of an empty `List`
will result in a `NoSuchElementException` being thrown.

This fix comes with no tests because the ticket didn't provide a reproducible
test case.

Fix #1001707
(cherry picked from commit a5aa9f4cecff5b9312dd6b60699c6827e75193a6)