The original implementation file contains both nodes definition and detection logics. This patch splits the two parts.