First calculate nodes for leaves present at height h
let i = X ; while ( nodes_last_level > 1 && i > 0 ) { nodes_last_level = Math . floor ( Math . ceil ( nodes_last_level / 2 ) ) ; i -- ; } from_leaf = nodes_last_level ;