'This function merges an app.yaml file with referenced builtins/includes.'

@classmethod
def MergeAppYamlAppInclude(cls, appyaml, appinclude):

    if (not appinclude):
        return appyaml
    if appinclude.handlers:
        tail = (appyaml.handlers or [])
        appyaml.handlers = []
        for h in appinclude.handlers:
            if ((not h.position) or (h.position == 'head')):
                appyaml.handlers.append(h)
            else:
                tail.append(h)
            h.position = None
        appyaml.handlers.extend(tail)
    appyaml = cls._CommonMergeOps(appyaml, appinclude)
    appyaml.NormalizeVmSettings()
    return appyaml
