Improve the algorithm that marks which actions are needed by FuncNode