use depth-first algorithm for better performance
use list for better performance
refactoring
refactoring
rename an exported function
refactoring
refactoring