lojix/wam_prolog/src/main/com/thesett/aima/logic/fol/wam/compiler/TopLevelCheckVisitor.java
private boolean isTopLevel()
    {
        if (traverser.isTopLevel())
        {
            return true;
        }
        else
        {
            PositionalContext parentContext = traverser.getParentContext();

            if (parentContext != null)
            {
                Term parentTerm = parentContext.getTerm();

                if ((parentTerm instanceof Conjunction) || (parentTerm instanceof Disjunction))
                {
                    Boolean isTopLevel =
                        (Boolean) symbolTable.get(parentTerm.getSymbolKey(), SymbolTableKeys.SYMKEY_TOP_LEVEL_FUNCTOR);

                    return (isTopLevel == null) ? false : isTopLevel;
                }
            }
        }

        return false;
    }
private boolean isTopLevel()
    {
        if (traverser.isTopLevel())
        {
            return true;
        }
        else
        {
            PositionalContext parentContext = traverser.getParentContext();

            if (parentContext != null)
            {
                Term parentTerm = parentContext.getTerm();

                if ((parentTerm instanceof Conjunction) || (parentTerm instanceof Disjunction))
                {
                    Boolean isTopLevel =
                        (Boolean) symbolTable.get(parentTerm.getSymbolKey(), SymbolTableKeys.SYMKEY_TOP_LEVEL_FUNCTOR);

                    return (isTopLevel == null) ? false : isTopLevel;
                }
            }
        }

        return false;
    }
Functors are considered top-level when they appear at the top-level within a clause, or directly beneath a parent
conjunction or disjunction that is considered to be top-level.

@return <tt>true</tt> iff the current position is considered to be top-level.