The trick is that you temporarily remove the WPML filter hooks that manipulate the term query to only return terms in the current language. You return the filter hooks back to normal after getting the terms back in all languages.
The if ( $sitepress ) is there as a safety measure to avoid errors in case you disable WPML in the future.
Striving for originality, usability, simplicity and style — Frique builds jQuery and WordPress plugins and themes that make life a little easier. Frique cares and writes about web and software usability, performance, development workflow and desire for perfection.