IPublishedContent extension methods not available in c#

Hi, I regularly use in my razor views the extension methods listed in the Querying & Traversal documentation, such e.g. var root = Model.Content.AncestorOrSelf(1);

However, now I'm trying to build a more complex function to retrieve the same page located under another language, for a multi-language website. I can do that in the razor view, but I'd like to create a static helper method, instead, so that I can reuse it in different views, if needed.

It looks like this:

        public static List GetPageURLinAllLanguages(IPublishedContent content)
        {
            List links = new List();
        return links;
    }

As you can see, I passed the IPublishedContent. If I try to get the root node from this content, as I do in my views, like this:

        public static List GetPageURLinAllLanguages(IPublishedContent content)
        {
            List links = new List();
        var root = content.AncestorOrSelf(1);

        return links;
    }

I get AncestorOrSelf(1) underlined in red, and if I compile I get this error:

Error 6 'Umbraco.Core.Models.IPublishedContent' does not contain a definition for 'AncestorOrSelf' and no extension method 'AncestorOrSelf' accepting a first argument of type 'Umbraco.Core.Models.IPublishedContent' could be found (are you missing a using directive or an assembly reference?)

What am I missing? Can you help?


This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/53359-ipublishedcontent-extension-methods-not-available-in-c