treecheck() {
    local eclass_funcs="$(grep -r '()[ ]*{' /usr/portage/eclass/ | tr "\t" ' ' | sed 's/ //g' | grep -v ':#' | sed 's/()[ ]*{.*//g' | grep -v "\(\\$\|'\|\"\)" | sed 's:/usr/portage/eclass/::g' | sed 's/\.eclass//g' | grep -v 'tests/')"
    local ebuilds

    for eclass_func in ${eclass_funcs} ; do
        if [[ ">${1}<" == "><" ]] ; then
            ebuilds="$(grep --include='*.ebuild' -rPl "(^|[ \t])${eclass_func#*:}(\$|[ \t])" /usr/portage/)"
        else
            ebuilds="$(grep -Pl "(^|[ \t])${eclass_func#*:}(\$|[ \t])" ${1})"
        fi

        for ebuild in ${ebuilds} ; do
            grep "inherit.*${eclass_func%:*}" ${ebuild} &> /dev/null

            if [[ $? == 1 ]] ; then
                echo "${eclass_func#*:} used in ${ebuild}, but eclass ${eclass_func%:*} might be missing!"
            fi
        done
    done
}